tags:

views:

25

answers:

1

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!

A: 

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.

j_random_hacker