Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.
Computer Hope forum e-mail issues and down time
0 Members and 1 Guest are viewing this topic.
Can VBScript shut down a PC?
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
Can it shut down all PCs on a LAN?
arrComputer = Array("Computer1", "Computer2", "Computer3")For Each strComputer In arrComputer 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) NextNext
The only VBS I ever heard of it .vbs or VBScript
For Each objOperatingSystem in colOperatingSystems objOperatingSystem.Win32Shutdown(1)Next
For Each objOperatingSystem in colOperatingSystems objOperatingSystem.Win32Restart(1)Next
For Each objOperatingSystem in colOperatingSystems objOperatingSystem.Reboot(2)Next
I don't think there is a restart method to the Win32_OperatingSystem class. Try using the reboot method.Code: [Select]For Each objOperatingSystem in colOperatingSystems objOperatingSystem.Reboot(2)NextGood luck.
well, if this darn notepad had intellisense like the vb6 IDE...
Quote from: BC_Programmer on December 31, 2008, 01:31:51 PMwell, if this darn notepad had intellisense like the vb6 IDE...Excuses, excuses....