Custom Search

Monday, October 22, 2012

How to Restart computer through VBScript\QTP

strComputer = "ComputerName"
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

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.