[ACCEPTED]-How to force restart a Windows box using VBScript?-reboot
Accepted answer
Try replacing:
retVal = OpSys.Reboot()
With:
retVal = OpSys.Win32Shutdown(6)
0
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...
You can also try the psShutdown command 1 line utility from Sysinternals now Microsoft. http://technet.microsoft.com/en-us/sysinternals/bb897541.aspx
'*********************************************************
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.
Set Reset= WScript.CreateObject ("WScript.Shell")
Reset.run "shutdown -r -t 00", 0, True
Or..
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
0
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.