Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
What happens when you specify the full path to the PSKill EXE? –  Kev Jun 1 '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 1 '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 1 '12 at 22:25
    
@David: the "createobject" is instancing the WScript.Shell object. –  MikeAWood Jun 2 '12 at 1:45
add comment

2 Answers 2

up vote 0 down vote accepted

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?

share|improve this answer
    
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/<sitename>" and then "iisweb /start W3SVC/<sitename>" You will need the iisweb.vbs that should be located in the system32 folder. More info here microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/… –  MikeAWood Jun 2 '12 at 1:05
    
I think the problem was the object was already instantiated as "oShell", so I started using that and it worked. –  David Jun 4 '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 4 '12 at 21:09
add comment

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.

share|improve this answer
    
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 4 '12 at 22:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.