Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Batch File to check for a program running in memory  (Read 2761 times)

0 Members and 1 Guest are viewing this topic.

n2tech

  • Guest
Batch File to check for a program running in memory
« 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...
« Last Edit: July 15, 2007, 07:33:23 AM by patio »

Dark Blade

  • Forum Gaming Master


  • Adviser

    Thanked: 24
    • Yes
  • Experience: Experienced
  • OS: Windows XP
Re: Batch File to check for a program running in memory
« Reply #1 on: July 15, 2007, 12:45:15 AM »
Code: [Select]
@echo off
tasklist | find "iexplore.exe" && goto end
start iexplore.exe
:end

contrex

  • Guest
Re: Batch File to check for a program running in memory
« Reply #2 on: July 15, 2007, 01:34:35 AM »
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.

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