We have a site on our local IIS6 Windows 2003 server that occasionally locks up, and we would like a VbScript to kill the process. It is located in the system32 folder. I'm running these tests on the local machine.
For simplicity, my VbScript file simply has lines such as these:
Set WshShell = WScript.CreateObject("WScript.Shell")
WScript.Echo "PSKill.exe " & W3WP.ProcessId
WshShell.Run "PSKill.exe " & W3WP.ProcessId
WScript.Echo "Killed Process"
Obtained earlier in the script, W3WP.ProcessId contains the correct process ID. The script outputs to the screen:
PSKill.exe 6884
But the line that is supposed to execute the command does nothing.
If I type the command in, it works fine. Why does PsKill work fine when I type it, but not from VbScript?
Best Answer
Try swaping the line. This will have it show the process in its own window and wait for it to finish.
Of course if that goes too fast, you might have better luck piping it to a log file
It looks like it should work to me. Is the VBScript running under a user account with permissions to kill the task?