1

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?

David
  • 439
  • 1
  • 5
  • 17
  • What happens when you specify the full path to the PSKill EXE? – Kev Jun 01 '12 at 22:21
  • I tried that. Same thing. I have a copy of pskill.exe in c:\pskill.exe as well as c:\windows\system32\pskill.exe and still nothing happens. – David Jun 01 '12 at 22:23
  • Is WshShell.Run supposed to be instantiated somehow? I don't use VbScript often so I could be overlooking something obvious. – David Jun 01 '12 at 22:25
  • @David: the "createobject" is instancing the WScript.Shell object. – MikeAWood Jun 02 '12 at 01:45

2 Answers2

1

Try running it in the script with '-accepteula' as a command line argument. These tools pop up the EULA on their first run, and if there's nobody to click accept they tend to just hang.

devicenull
  • 5,622
  • 1
  • 26
  • 31
  • You were right, the Eula was getting in the way. The -accepteula flag though didn't help, I had to login as the other user and click on it. – David Jun 04 '12 at 22:05
0

Try swaping the line. This will have it show the process in its own window and wait for it to finish.

WshShell.Run "PSKill.exe " & W3WP.ProcessId, 1, true

Of course if that goes too fast, you might have better luck piping it to a log file

WshShell.Run "PSKill.exe " & W3WP.ProcessId & ">> log.txt"

It looks like it should work to me. Is the VBScript running under a user account with permissions to kill the task?

jscott
  • 24,484
  • 8
  • 79
  • 100
MikeAWood
  • 2,566
  • 1
  • 13
  • 13
  • I had to go back and look because it has been a while, but there is another command line for restarting a website in IIS on Windows Server 2003 running IIS6. Command is "iisweb /stop W3SVC/" and then "iisweb /start W3SVC/" You will need the iisweb.vbs that should be located in the system32 folder. More info here http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/d567048c-0171-4bc9-b084-b10f738fd964.mspx?mfr=true – MikeAWood Jun 02 '12 at 01:05
  • I think the problem was the object was already instantiated as "oShell", so I started using that and it worked. – David Jun 04 '12 at 16:53
  • You should be able to create the object twice. But if you already have it instanciated, then you should be able to reuse it.. – MikeAWood Jun 04 '12 at 21:09