3

I am having problems with the taskkill in batch, I am trying to kill a vbscript that is in sleep for an x amount of seconds. So basically I want to kill this task: https://i.stack.imgur.com/rxgAL.png

But I somehow seem to get it wrong, I have no clue what part of the task I have to write in the taskkill x

Thank you in advance!

Albert MN.
  • 713
  • 1
  • 16
  • 33

3 Answers3

3

This will kill it without knowing the pid, however it will kill all instances of wscript.exe.

TASKKILL /F /IM wscript.exe
aphoria
  • 19,796
  • 7
  • 64
  • 73
  • I dont run any other wscript files, so I think that would be fine... Does windows by default run any wscripts? Or does any programs...? Like, I don't want it to kill something it shouldn't – Albert MN. May 29 '15 at 19:13
2

From the task manager top menu, select to show the Process ID for this running process.

Then on command prompt,

  taskkill /pid 1234

Where 1234 id the Process ID you want to kill.

MTahir
  • 1,173
  • 1
  • 13
  • 25
  • Does it always have the same ID..? And how do I find the ID...? xD – Albert MN. May 29 '15 at 18:28
  • See this [post](http://stackoverflow.com/q/8435952/833786) to look for process ID using command line – MTahir May 29 '15 at 18:32
  • So, I cant possibly make a batch file kill a specific task? And there is no way to 'get task' or something...? Or maybe just a way to cancel and close a vbscript from its' sleep...? :)' – Albert MN. May 29 '15 at 18:33
  • what does this script do and why do you want to kill it? – MTahir May 29 '15 at 18:35
  • 1
    I want to kill it/cancel a sleeping vbscript for another, new/updated one to replace it. I am making an Automatic Shutdown batch (oh how original), I have a vbscript showing 5 minutes before shutdown, asking if you want to cancel - but if I set the shutdown, decide to chance the time (in a controlpanel), the vbscript from the 'old' shutdown is still in sleep mode, so both scripts will be showing. Now back on track... Though, I got this: for /f "tokens=2" %%a in ('tasklist^|find /i "wscript.exe"') do (set pid=%%a) ^ How do I get that to get a specific wscript, my wscript, and not any other? – Albert MN. May 30 '15 at 13:25
2

VBScripts do have a timeout parameter - see cscript /?.

taskkill /im wscript.exe /im cscript.exe /f

will kill all running vbscripts.

If you want to be particular how do you tell the running scripts apart.