Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Check if a process is already running

Posted on 2007-10-17
1
Medium Priority
?
448 Views
Last Modified: 2012-06-22
I would like to use a simple DOS batch file to check if an app (process) is already running and if so, exit.  If it is not running, I'd like to start the app.  It would run on a Windows XP machine.  I'm thinking tlist.exe is the solution, but don't know how to apply it.

Thanks.
0
Comment
Question by:SophiG
1 Comment
 
LVL 72

Accepted Solution

by:
Qlemo earned 200 total points
ID: 20095258
Two of several possible solutions:

- Build-in tools:
tasklist  /fi "imagename eq taskmg.exe" 2>nul | findstr .exe  >nul && echo is running

- pslist from sysinternals.com
pslist taskmgr.exe 2>nul >nul && echo is running

&& does exexute only if errorlevel is 0 (success).
|| executes when failed.

Both ways, you can start your program with one single line.
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question