Computer Hope
Microsoft => Microsoft Windows => Windows XP => Topic started by: n2tech on July 14, 2007, 08:46:58 PM
-
I need to have a way to check and see if a program is running then open it if it is not running. This is basically what I need:
If Program is running
Goto End
Else Start Program
End
Can anyone help with this?
Thanks,
Mark Sharp
N2Tech
E-Mail address edited out to prevent spam...
-
@echo off
tasklist | find "iexplore.exe" && goto end
start iexplore.exe
:end
-
Or you can use handle.exe from the Microsoft Sysinternals collection of utilities.
And you can use the start "" "program.exe" format to make the batch continue & maybe exit.
http://www.microsoft.com/technet/sysinternals/Processesandthreadsutilities.mspx?wt.svl=featured
And just to be contrary, I show the use of || thus avoiding the use of a label. In fact by choosing && or || appropriately you never need use labels.
handle | find /i "extradns.dll" > nul || (
echo ExtraDNS not detected - starting now!
start "" "C:\Program Files\ExtraTools\ExtraDNS\ExtraDNS.exe"
)