Test if a Windows-based Application is Running

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
jonno
Posts: 1
Joined: 14 Aug 2008 10:15
Location: MN, USA

Test if a Windows-based Application is Running

#1 Post by jonno » 14 Aug 2008 10:26

Hello,

I've spent a few hours googling and have come up empty.

I need to create a DOS script (I call them batch files) where I test if a windows based application is running. If so, I want to set focus to the application (similar to the API function 'ShowWindow' or 'SetForegroundWindow'). and if the app is not running - simply run it.

Thanks for any direction on this.

Jon

Skeletor
Posts: 3
Joined: 01 Sep 2008 12:50
Location: Manchester(England)

Re: Test if a Windows-based Application is Running

#2 Post by Skeletor » 04 Sep 2008 06:21

jonno wrote:Hello,

I've spent a few hours googling and have come up empty.

I need to create a DOS script (I call them batch files) where I test if a windows based application is running.


@echo off
IF "%1" == "" (Echo Syntax... istask {task}&pause&GOTO :eof)
set task=%1
set task=%task:"=%
tasklist /FI "IMAGENAME eq %task%" | find /i "%task%" >NUL:
goto task%ERRORLEVEL%
:task0
Echo INFO: Found task %task%
goto :eof
:task1 Start it
"%task%"
goto :eof

Post Reply