I'm trying to find a way to force Windows to reboot, and I am running into issues. I've tried
Set OpSysSet = GetObject("winmgmts:{authenticationlevel=Pkt," _
& "(Shutdown)}").ExecQuery("select * from Win32_OperatingSystem where "_
& "Primary=true")
for each OpSys in OpSysSet
retVal = OpSys.Reboot()
next
I've also tried using the shutdown -f -r
command, and in both cases I sometimes get no response, and if I try again I get an error saying "Action could not complete because the system is shutting down" even though no matter how long I leave it it doesn't shut down, it still allows me to start new programs, and doing a shutdown -a
gives the same error. How can a script be used to force Windows to reboot?
set objShell = wscript. CreateObject("wscript. shell") objShell. Run "shutdown.exe /R /T 5 /C ""Rebooting your computer now!
Type msconfig in the search box, and select System Configuration from the list of results. Select the Services tab, and then select Hide all Microsoft services. Select each of the check boxes in the upper half of the Service list. Select OK, then select Restart.
Try replacing:
retVal = OpSys.Reboot()
With:
retVal = OpSys.Win32Shutdown(6)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With