How to tastkill.

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
MLGsuperGame414
Posts: 54
Joined: 10 Nov 2011 20:40

How to tastkill.

#1 Post by MLGsuperGame414 » 21 Dec 2011 18:15

im trying to get this batch file to kill the task a user gives it. Via process ID
not sure why this isnt working but im sure someone good with this stuff could help me.


Code: Select all

@Echo off 
CLS
:Testing:
CLS
Echo.
set %process_ID%
set/p %process_ID%=Enter the process ID you wish to terminate.
pskill [-t] \\superk-12281ad8 %process_ID%

taripo
Posts: 228
Joined: 01 Aug 2011 13:48

Re: How to tastkill.

#2 Post by taripo » 21 Dec 2011 19:00

Firstly you misspelt your subject, it's taskkill not tastkill.

Secondly, pskill is part of sysinternals. So you need to have pstools installed, unless perhaps it's part of windows.

Thirdly, taskkill is even in windows xp.
taskkill /pid 1234

Fourthly, pskill [-t] is clearly not going to work. If you look at any command /?, then you see [..] is not how you use the command. It just means that the -t is optional. I haven't used pskill myself.. But make sure you know how to use it manually before you start wondering why your batch file isn't working.
pskill looks like it will let you kill a task on another computer. That's something taskkill can't do. Try pskill -t ........

Fifthly
set %process_ID%
set/p %process_ID%=
probably should be
set process_ID
set/p process_ID=

MLGsuperGame414
Posts: 54
Joined: 10 Nov 2011 20:40

Re: How to tastkill.

#3 Post by MLGsuperGame414 » 21 Dec 2011 20:21

Ops typo thanks man! So like this?

Code: Select all

@echo off
:TaskKill Testing:
set process_ID
set/p process_ID=Enter the process ID you wish to terminate
taskkill \\superk-12281ad8 process_ID

taripo
Posts: 228
Joined: 01 Aug 2011 13:48

Re: How to tastkill.

#4 Post by taripo » 22 Dec 2011 06:46

are you trying to kill a task on a remote machine? in which case i'm not sure off hand.

If you just want to kill a task on the current machine, then you can forget a batch file, just

taskkill /pid 1234

If you have to use a batch file then

call it by doing
C:\>blah 1234<ENTER>

and blah.bat contains one line.
@taskkill /pid %1 >nul

that >nul means it hides whatever the output is.
Try removing it and you see the difference with it and without it.

Post Reply