1.

Solve : Batch File to check for a program running in memory?

Answer»

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... Code: [Select]echo off
tasklist | find "iexplore.exe" && goto end
start iexplore.exe
:endOr 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.

Quote

handle | find /i "extradns.dll" > nul || (
        echo ExtraDNS not detected - starting now!
        start "" "C:\Program Files\ExtraTools\ExtraDNS\ExtraDNS.exe"
        )



Discussion

No Comment Found