1) Getting Local Computer Information
Set objComputer = CreateObject("Shell.LocalMachine")
Wscript.Echo "Computer name: " & objComputer.MachineName
Wscript.Echo "Shutdown allowed: " & objComputer.IsShutdownAllowed
Wscript.Echo "Friendly UI enabled: " & objComputer.IsFriendlyUIEnabled
Wscript.Echo "Guest access mode: " & objComputer.IsGuestAccessMode
Wscript.Echo "Guest account enabled: " & _
objComputer.IsGuestEnabled(0)
Wscript.Echo "Multiple users enabled: " & _
objComputer.IsMultipleUsersEnabled
Wscript.Echo "Offline files enabled: " & _
objComputer.IsOfflineFilesEnabled
Wscript.Echo "Remote connections enabled: " & _
objComputer.IsRemoteConnectionsEnabled
Wscript.Echo "Undock enabled: " & objComputer.IsUndockEnabled
Wscript.Echo "Multiple users enabled: " & _
objComputer.IsMultipleUsersEnabled
Wscript.Echo "Offline files enabled: " & _
objComputer.IsOfflineFilesEnabled
Wscript.Echo "Remote connections enabled: " & _
objComputer.IsRemoteConnectionsEnabled
Wscript.Echo "Undock enabled: " & objComputer.IsUndockEnabled
2) Restart a Computer
strComputer = "atl-dc-01"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(Shutdown)}!\\" & _
strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
objOperatingSystem.Reboot()
Next
strComputer = "atl-dc-01"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(Shutdown)}!\\" & _
strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
objOperatingSystem.Reboot()
Next
3) Shut Down a Computer
strComputer = "."
Set objWMIService = GetObject_
("winmgmts:{impersonationLevel=impersonate,(Shutdown)}\\" & _
strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
objOperatingSystem.Win32Shutdown(1)
Next
strComputer = "."
Set objWMIService = GetObject_
("winmgmts:{impersonationLevel=impersonate,(Shutdown)}\\" & _
strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
objOperatingSystem.Win32Shutdown(1)
Next
4) Modify System Startup Delay
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colStartupCommands = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")
For Each objStartupCommand in colStartupCommands
objStartupCommand.SystemStartupDelay = 10
objStartupCommand.Put_
Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colStartupCommands = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")
For Each objStartupCommand in colStartupCommands
objStartupCommand.SystemStartupDelay = 10
objStartupCommand.Put_
Next
No comments:
Post a Comment