Computing.Net > Forums > Programming > A batch file to kill a process

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

A batch file to kill a process

Reply to Message Icon

Name: Stella Yang
Date: June 17, 2005 at 07:44:26 Pacific
OS: windows XP
CPU/Ram: 2.0 GHz and 512 MB
Comment:

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.



Sponsored Link
Ads by Google

Response Number 1
Name: Dr. Nick
Date: June 17, 2005 at 11:25:42 Pacific
Reply:

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?


0

Response Number 2
Name: Stella Yang
Date: June 17, 2005 at 11:47:49 Pacific
Reply:

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)"....


0

Response Number 3
Name: Dr. Nick
Date: June 17, 2005 at 13:21:04 Pacific
Reply:

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?


0

Response Number 4
Name: jackpot18901
Date: January 4, 2006 at 10:28:11 Pacific
Reply:

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.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: A batch file to kill a process

Batch File To Kill A Process www.computing.net/answers/programming/batch-file-to-kill-a-process-/18460.html

Batch File to Create a Shortcut www.computing.net/answers/programming/batch-file-to-create-a-shortcut/13374.html

Batch file to insert string www.computing.net/answers/programming/batch-file-to-insert-string-/19385.html