Solved A batch file to kill a process

June 17, 2005 at 07:44:26
Specs: windows XP, 2.0 GHz and 512 MB
I am trying to create a batch file to kill a process only if it is running. I found a pskill tool from windows xp tool site but when I put it in the batch file and scheduled the task, a black window always flash to kill the process no matter if it is running or not. My question is:
1. How do I put it in the batch to run this pskill by detecting if it alive first.
Or--2. How do I get this scheduled task run minimized or another secretive way? I don't want to see the black window popping up.
Thanks a lot if you could help me! Note: I can make the batch file run minimized from its property setting but when it is in scheduled task, I couldn't get it to minimize anymore.


See More: A batch file to kill a process

Report •


✔ Best Answer
January 4, 2006 at 10:28:11
You can use the TASKKILL command with the /FI switch that has an operator of e and a value of RUNNNING
It might look something like this:
TASKKILL /F /IM notepad.exe /FI STATUS ne RUNNING

Type the TASKKILL /? to see all the possible filers,operators and values.



#1
June 17, 2005 at 11:25:42
How are you trying to kill the task? I've used pskill before, and while it's nice, you could just use the built-in program, TASKKILL.

Just run it like this to use the program name:

TASKKILL /F /IM "notepad.exe"

Or this to kill it based on the process ID:

TASKKILL /F /PID 1234

Does that work?


Report •

#2
June 17, 2005 at 11:47:49
Dr. Nick,
Thanks! I simply not aware of that command. But pskill command does the same -- pskill notepad.exe.

I still have the same problem with taskkill when it is in scheduled task with a black window popping up to kill the process even if the process is not running. Anyway to avoid that? Are you aware of any DOS command to run conditioned command? Like "if EXIST (processname). (taskkill processname)"....


Report •

#3
June 17, 2005 at 13:21:04
Are you just trying to prevent the black box from poping up? If this is the case then even if you got the If statement to work you'd still see the black box.

I'm not sure if there's a way to run that command without seeing the command window. The box only pops up for a second, why is that a problem?


Report •

Related Solutions

#4
January 4, 2006 at 10:28:11
✔ Best Answer
You can use the TASKKILL command with the /FI switch that has an operator of e and a value of RUNNNING
It might look something like this:
TASKKILL /F /IM notepad.exe /FI STATUS ne RUNNING

Type the TASKKILL /? to see all the possible filers,operators and values.


Report •


Ask Question