How to check if a particular command line is running in cmd propmt
I desperately need help to create a vb / dos code which will do the following: Check if a command prompt window is running with the following command: mgms A1 (mgms is a custom command) If it is running, exit. If it is not running, start cmd prompt and run开发者_开发技巧 the command , exit
Thanks a lot for your help!
The Windows cmd.exe
batch language is horrible, but you should be able to put this in a batch file and get it working:
tasklist /FI "IMAGENAME eq mgms.exe" 2>&1 | findstr /B "INFO: No tasks running" > tmp
for /F "delims=" %x in (tmp) do mgms A1
You may need to further check that the command-line arguments to mgms.exe match what you expect -- have a look at the help for tasklist.exe
and findstr.exe
. Both programs are both standard in WinXP Pro and up, I believe. If you don't have them, I'm sure you can find them or (near) equivalents on the web.
精彩评论