I\'d like to write a batch file that checks to see if a process is running, and takes one action if it is, and another action if it isn\'t.
I know I can use tasklist
You can use "for /f" construct to analyze program output.
set running=0
for /f "usebackq" %%T in (`tasklist /nh /fi "imagename eq firefox.exe"`) do set running=1
Also, it's a good idea to stick a
setlocal EnableExtensions
at the begginning of your script, just in case if the user has it disabled by default.
Some options:
http://www.windowsdevcenter.com/pub/a/oreilly/windows/news/win2kcommands_0401.html#ps
http://www.windowsdevcenter.com/pub/a/oreilly/windows/news/win2kcommands_0401.html#ps