Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I run a few batch files as SYSTEM (as services) and they appear as cmd.exe in tasklist. Sometimes I need to terminate one of them but I cannot decide which cmd.exe to terminate.

Plus; I run many batch files as scheduled tasks, all appear as cmd.exe (with my account)

How can I mark a batch file, so I can recognize it at task manager?

share|improve this question
up vote 6 down vote accepted

open Task Manager, click on the Processes tab, and select View->Select Columns.... Turn the checkbox Command Line on. Now Task Manager will show you, for each cmd.exe, what it is running. For a batch file this looks like

cmd /c ""C:\path\to\test.bat""

For your question on making sure only a single instane can run, this rather dirty trick works:

@echo off

tasklist /v | find /I /c "MyUniqueTitle" > nul
if "%ERRORLEVEL%" == "0" goto ErrorAlreadyRunning

title MyUniqueTitle
echo "Running as Single Instance!"
goto end

echo "ErrorAlreadyRunning"

share|improve this answer
oops seems you removed the single instance question already :] – stijn Nov 28 '11 at 14:35
That "MyUniqueTitle" label may work... – Nime Cloud Nov 28 '11 at 15:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .