0

I am writing a simple batch file to start programs.

What command(s) do I use to have the batch file FIRST check (automatically) to see if a program is running, and run the program if it is NOT already running?

[[ Thanks in advance, I've looked and I just can't seem to find the answer. ]]

pradeep
  • 155
  • 1
  • 4
  • 14
  • 2
    Have you seen this? Seems to do what you want... http://stackoverflow.com/questions/162291/how-to-check-if-a-process-is-running-via-a-batch-script – Gk3Biz Aug 29 '13 at 03:50

1 Answers1

1

Try this:

 TASKLIST /FI "IMAGENAME eq processName.exe" /FI "status eq running" | find /I /N "processName.exe">NUL
IF ("%ERRORLEVEL%"=="0" echo Process is running) ELSE (start "processName.exe")
r3ap3r
  • 2,775
  • 2
  • 17
  • 16