VBS File Examples
Message Box
Dim strMessage
strMessage = "Compile scripts into stand-alone applications"
MsgBox strMessage
Reboot
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
To shut down the machine, change the OpSys.Reboot() line to
OpSys.Shutdown().
Call Windows shutdown choice popup
set WshShell = wscript.CreateObject("Shell.Application")
WshShell.ShutdownWindows
See also:
Tips for Writing VBS
Files
Copyright © ScriptCode.com 2010. All rights reserved.