How to force restart a Windows box using VBScript?

Try replacing:

retVal = OpSys.Reboot()

With:

retVal = OpSys.Win32Shutdown(6)

Well, this uses VBScript -- although truthfully it invokes the same command line shutdown that you're trying to do. I've tested it and it works.

Dim oShell 
Set oShell = CreateObject("WScript.Shell")

'restart, wait 5 seconds, force running apps to close
oShell.Run "%comspec% /c shutdown /r /t 5 /f", , TRUE

What OS are you running against? This test was against XP. I wonder if the server OS requires a shutdown code...


You can also try the psShutdown command line utility from Sysinternals now Microsoft. http://technet.microsoft.com/en-us/sysinternals/bb897541.aspx