A. To reboot the local machine from a VBScript script, you can use the following code. For the code to work, Windows Management Instrumentation (WMI) must be installed on the machine you're rebooting.
Set OpSysSet = GetObject("winmgmts:\{(Shutdown)\}//./root/cimv2").ExecQuery_ ("select * from Win32_OperatingSystem where Primary=true") for each OpSys in OpSysSet OpSys.Reboot() next
(The GetObject line wraps to two lines here because of space constraints.) To shut down the machine, change the OpSys.Reboot() line to OpSys.Shutdown(). You can download the script here.
8 comments
Hide comments