[ACCEPTED]-How to force restart a Windows box using VBScript?-reboot

Accepted answer
Score: 10

Try replacing:

retVal = OpSys.Reboot()


retVal = OpSys.Win32Shutdown(6)


Score: 4

Well, this uses VBScript -- although truthfully 5 it invokes the same command line shutdown 4 that you're trying to do. I've tested it 3 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 2 test was against XP. I wonder if the server 1 OS requires a shutdown code...

Score: 3

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

Score: 2

Option Explicit

Dim objShell

Set objShell = WScript.CreateObject("WScript.Shell")

objShell.Run "C:\WINDOWS\system32\shutdown.exe -r -t 0"


This little script restarts the local computer 1 after 0 seconds.

Score: 0
Set Reset= WScript.CreateObject ("WScript.Shell")

Reset.run "shutdown -r -t 00", 0, True


Shell "shutdown -r -t 00"   ' for restart

Shell "shutdown -s -t 00"  ' for Shutdown

Shell "shutdown -l -t 00"   ' for log off

Shell "shutdown -a -t 00"  ' for abort


More Related questions