Login | |
|
 |
RE: what is wrong with this script - 5/17/2006 7:57:38 PM
|
|
 |
|
| |
ginolard
Posts: 1068
Score: 21
Joined: 8/10/2005
Status: offline
|
Because you're not iterating through the array. arrComputers = Array("1","2") For i = 0 to Ubound(arrComputers) Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate,(Shutdown)}!\\" & _ arrComputers(i) & "\root\cimv2") Set colOperatingSystems = objWMIService.ExecQuery _ ("Select * from Win32_OperatingSystem") For Each objOperatingSystem in colOperatingSystems objOperatingSystem.Reboot() Next Next
_____________________________
Author of ManagePC - http://managepc.net AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm
|
|
| |
|
|
|
 |
RE: what is wrong with this script - 5/18/2006 12:30:43 AM
|
|
 |
|
| |
gdewrance
Posts: 587
Score: 3
Joined: 3/16/2006
Status: offline
|
Try this script from Mark '========================================================================== ' ' NAME: RebootWSfromList.vbs ' ' AUTHOR: Mark D. MacLachlan , The Spider's Parlor ' URL: http://www.thespidersparlor.com ' DATE : 7/6/2004 ' ' COMMENT: <comment> ' '========================================================================== On Error Resume Next 'open the file system object Set oFSO = CreateObject("Scripting.FileSystemObject") set WSHShell = wscript.createObject("wscript.shell") 'open the data file Set oTextStream = oFSO.OpenTextFile("wslist.txt") 'make an array from the data file RemotePC = Split(oTextStream.ReadAll, vbNewLine) 'close the data file oTextStream.Close For Each strComputer In RemotePC Set OpSysSet = GetObject("winmgmts:{impersonationLevel=impersonate,(RemoteShutdown)}//" & strComputer).ExecQuery("select * from Win32_OperatingSystem where Primary=true") for each OpSys in OpSysSet OpSys.Reboot() next Next Hope this helps
|
|
| |
|
|
|
 |
RE: what is wrong with this script - 5/18/2006 7:27:44 PM
|
|
 |
|
| |
gdewrance
Posts: 587
Score: 3
Joined: 3/16/2006
Status: offline
|
just google vbscript runas I think thats what you after
|
|
| |
|
|
|
 |
RE: what is wrong with this script - 5/18/2006 7:35:38 PM
|
|
 |
|
| |
gdewrance
Posts: 587
Score: 3
Joined: 3/16/2006
Status: offline
|
if you need to reboot them every week , use devcon and set it as a scheduled task I use it for my servers to restart on weekends when no ones around if xp try start run shutdown -i hope this helps
|
|
| |
|
|
|
 |
RE: what is wrong with this script - 5/18/2006 7:50:29 PM
|
|
 |
|
| |
gdewrance
Posts: 587
Score: 3
Joined: 3/16/2006
Status: offline
|
you will need to do somthing like thie Dim co As New ConnectionOptions co.Impersonation = ImpersonationLevel.Impersonate co.EnablePrivileges = True co.Username = "domain\username" 'domain admin co.Password = "Password"
|
|
| |
|
|
|
 |
RE: what is wrong with this script - 5/18/2006 11:17:03 PM
|
|
 |
|
| |
mbouchard
Posts: 1916
Score: 16
Joined: 5/15/2003
From: USA
Status: offline
|
Also, you can take a look at psShutdown from sysinternals. This allows you to supply a username and password to shutdown a remote PC.
_____________________________
Mike For useful Scripting links see the Read Me First stickey! Always remember Search is your friend.
|
|
| |
|
|
|
|
|