Question

Reboot Computers In Multiple OU's VBscript

Asked by: pbest93

Hi Experts,

I am trying to get a vb script that will reboot all computers in several OU's I have in our Server 2003 environment (all clients are XP SP3).

Here's what the script should do:
1. Iterate through several OU's
2. check/ping computer to make sure its available
3. if computer is up, reboot

I would prefer to use psshutdown because some of the options it offers (force, message to user, wait time, etc), but if thats not an option, its not a deal breaker.

I have tried this in a few different ways, and nothing has worked like I want, thought I could get some help here.

My vbs skills are so-so, but I know very, very little about WMI.

I *do not* want a batch file/script that I have to supply a txt file with all the computer to it in. We have that already, and we push out so many computers I would be generating a new txt file every week.

II have looked at the following examples, but can't piece it all together:
http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Server/2003_Server/Q_22053520.html?sfQueryTermInfo=1+10+comput+ou+reboot+vb
http://blog.netnerds.net/2006/12/vbscript-output-snippet
http://www.wisesoft.co.uk/scripts/vbscript_shutdown_all_computers_in_an_organizational_unit.aspx

Thanks, let me know if you need any more information!

'http://www.wisesoft.co.uk/scripts/vbscript_shutdown_all_computers_in_an_organizational_unit.aspx
 
OPTION Explicit
DIM cn,cmd,rs,i
DIM objRoot
DIM strFilter, strScope
 
' Specify OU(s) of computers you want to shutdown
DIM strRoot(3)
strRoot(0) = "ou=restart01,dc=domain,dc=local"
strRoot(1) = "ou=restart02,dc=domain,dc=local"
strRoot(2) = "ou=restart03,dc=domain,dc=local"
 
' Default filter for computer objects
' You might want to use a different filter.  By operating system for example:
' (&(objectCategory=Computer)(operatingSystem=Windows XP*))
strFilter = "(objectCategory=Computer)"
' Search child organizational units.  Use "onelevel" to search only the specified OU.
strScope = "subtree"
' *******************************************************************
 
'Start for loop to reboot computers in each of the OU's
For i = 0 to 2
	set cmd = createobject("ADODB.Command")
	set cn = createobject("ADODB.Connection")
	set rs = createobject("ADODB.Recordset")
 
	cn.open "Provider=ADsDSOObject;"
	cmd.activeconnection = cn
 
	cmd.commandtext = "<LDAP://" & strRoot(i) & ">;" & strFilter & ";" & _
			  "name;" & strScope
	'**** Bypass 1000 record limitation ****
	cmd.properties("page size")=1000
 
	set rs = cmd.execute
 
	while rs.eof <> true and rs.bof <> true
		'wscript.echo "Shutting Down " & rs("name") & "..."
		ShutDownComputer(rs("name"))
 
		rs.movenext
	wend
 
	cn.close
Next
 
	' Subroutine to shutdown a computer
	sub ShutDownComputer(byval strComputer)
		dim strShutDown,objShell
		' I played around with making sure the computer was pingable, but never got it to work. Here is what I was working off of:
                                          ' http://blog.netnerds.net/2006/12/vbscript-output-snippet/
                                          '
                                          'Set objWMIService = GetObject("winmgmts:\.\root\cimv2")
                                          'strComputer =  "myServer.myDomain.net"
                                          'Set colItems = objWMIService.ExecQuery("Select * from Win32_PingStatus Where Address = '" & strComputer & "'")
                                          '          For Each objItem in colItems
                                          '              If objItem.StatusCode = 0 Then 'The Computer is Pingable
                                          '              msgbox "Woot"
                                          '              End if
                                          '         Next
                                          'Set objWMIService = Nothing
		' -s = shutdown, -t 60 = 60 second timeout, -f = force programs to close
		strShutdown = "C:\bin\restart_computers\psshutdown.exe -r -f -c -t 300 -e p:0:0 -m " & chr(34) & "Nightly restart of computer" & chr(34) & " \\" & strComputer
 
			set objShell = CreateObject("WScript.Shell") 
 
			objShell.Run strShutdown, 0, false
 
	end sub

                                  
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:

Select allOpen in new window

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-04-06 at 08:57:54ID24298702
Tags

AD

,

GPO

,

VBS

,

VBscript

Topics

VB Script

,

Active Directory

,

Scripting Languages

Participating Experts
2
Points
500
Comments
15

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. VBScript to create a list of all users in AD and in what OU
    Hi! I'm looking for a VBScript that export a list of all user accounts in an AD to a texfile. The list should include "User Logon Name", "First name", Last name" and in what OU it resides.
  2. Build OU List
    Hello I need help creating a vbscript to create a list of active directory tree OU in this format: OU=blablabla,OU=blablablabla OU=blablabla,OU=blablablabla OU=blablabla,OU=blablablabla OU=blablabla,OU=blablablabla
  3. VBscript to check if an OU's object (let's say string AC…
    I am looking for a VBscript to check if an OU's object (let's say string ACB) is a user or a group in that OU.
  4. Need a VBScript to shutdown all computers in one OU with…
    I need a VBScript which will shutdown all servers in ONE OU without affecting the sub OU's in the OU I need to target. Many, many thanks in advance!
  5. VBscript display users profile within OU
    Hi there, I am looking for VBscript that display users profile within OU. Can anyone help me please? Thanks
  6. Vbscript OU path of mailbox
    Hi, I need help with a vbscript, which will return the full OU path of each mailbox in exchange 2003 server. Thank You

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: jared_lukerPosted on 2009-04-06 at 09:17:17ID: 24078868

Here is one that I did using the Exec method to ping and using psshutdown to do the actual rebooting.  You would just need to tweak it to work with your AD query.

SET objFSO = CreateObject("Scripting.FileSystemObject")
SET objInputfile = objFSO.OpenTextFile("ActiveHosts.txt")
SET objOutputfile = objFSO.CreateTextFile("log.txt", True)
 
 
'DO WHILE NOT objInputfile.AtEndOfStream
'strComputer = objInputfile.readline
SET objShell = CreateObject("WScript.Shell")
Set objExec = objShell.Exec("ping -n 2 -w 1000 " & strComputer)
strPingResults = LCase(objExec.StdOut.ReadAll)
'WScript.Echo strPingResults
If InStr(strPingResults, "ttl") THEN
	WScript.echo strComputer' & " PING = YES "
	objshell.Run ("c:\pstools\psshutdown -f -r -t 03:00 \\" & strComputer
	Results = LCase(objExec.StdOut.ReadAll)
	WScript.Echo Results
Else
	objOutputfile.writeline strComputer & " PING = NO"
End IF
LOOP
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:

Select allOpen in new window

 

by: pbest93Posted on 2009-04-06 at 09:23:29ID: 24078932

Hi Jared,

Thanks for the reply.

I see what you are doing, but I am stuck on how to tie this in with the results from the OU enumeration and only run this against machine in those OU's.

Any help with that part?

Thanks!

 

by: jared_lukerPosted on 2009-04-06 at 09:31:30ID: 24079020

Well... I'm not 100% sure about the variables the person that wrote that is using, but it seems to me that you would want to put it inside that While...Wend loop.  You need to set whatever variable stores the current computer to be worked on as strComputer.  I think if you can get that figured out, as it runs through the loop for every machine it should reboot the ones that can be pinged and skip the ones that can not.

 

by: pbest93Posted on 2009-04-06 at 09:34:27ID: 24079045

ok, i will try it out some today, and tonight will let it run in a few test ou's that are in production

if it works/doesnt work, i will let you know

thanks jared

 

by: jared_lukerPosted on 2009-04-06 at 09:40:12ID: 24079098

I can use a script like this myself, so I'm trying to make it work as well.  I'll let you know if I don't hear from you first.

 

by: bluntTonyPosted on 2009-04-06 at 10:28:58ID: 24079619

Your code is basically sound. You need to perform a seperate query for each search base, return the computer names in the query recordset, then loop through these and issue the command to shut them down.

A couple of things

1. You didn't append the DNS suffix to the machine name, this is effectively the NetBIOS name - this may or may not be a problem for you, but you can append the DNS suffix to ensure it's not.

2. Personally I wouldn't worry about pinging the machine. If it's contactable you can shut it down. If it's not, then you can't. Just issue the command via the shell object but don't wait for the command to complete. If it shuts it down, great, if not, then you don't have to wait for a ping timeout. If the ping times out, all you're going to do is continue anyway. Currently your code isn't waiting for the run command to complete anyway and you'e got no feedback, so you've currently got nothing to benefit from pinging the machine. (my opinion at least :-) )

3. You can use psshutdown if you prefer, but the in-built shutdown.exe basically does everything you need. You can force a reboot, give a wait period and send a message to the machine to allow them to cancel if they need to.

4. If you're not waiting for the process to complete, I would add a periodic pause in your code so that you don't end up with hundreds of psshutdown.exe processes running on your machine. The code below currently pauses for 5 secs every 10 commands issues. You can change this as you see fit - this section is commented.

I haven't actually tested the shutting down of machines with this code (I may get sacked), so I haven't been able to check the pshsutdown syntax, but it successfully enumerates the machines in each OU specified in the strRoot array and appends the given DNS suffix (strDNSSuffix). Bear in mind that it also currently searches all sub OUs of each search base.

Let us know how you get on....

Dim strRoot(2)
Dim strFilter, strAttrs, strScope, strDNSSuffix, strBase
Dim objConn, objRS
 
strRoot(0) = "OU=Member Servers,DC=domain,DC=local"
strRoot(1) = "OU=Domain Controllers,DC=domain,DC=local"
strRoot(2) = "OU=Workstations,OU=Computers,OU=MyBusiness,DC=domain,DC=local"
 
strFilter = "(objectclass=computer);"
strAttrs  = "name;"
strScope  = "subtree"
 
strDNSSuffix = ".domain.local"
 
'This is your main loop, each time a different search base.
For i = 0 To UBound(strRoot) 
	strBase   =  "<LDAP://" & strRoot(i) & ">;"
	Set objConn = CreateObject("ADODB.Connection")
	objConn.Provider = "ADsDSOObject"
	objConn.Open "Active Directory Provider"
	Set objRS = objConn.Execute(strBase & strFilter & strAttrs & strScope)
 
	objRS.MoveFirst
	'This is your inner loop, each time an individual PC found in the search of the base.
	While Not objRS.EOF
		ShutDownComputer(objRS.Fields("name").Value & strDNSSuffix)
		'For every 10 records looped through. Pause for 5 secs.....
		If objRS.Bookmark Mod 10 = 0 Then
			WScript.Sleep 5000
		End If
		objRS.MoveNext
	Wend
	
	Set objConn = Nothing
	Set objRS = Nothing
	
Next 'i
 
 
Sub ShutDownComputer(byval strComputer)
Dim strShutDown,objShell
 
strShutDown = "C:\bin\restart_computers\psshutdown.exe -r -f -c -t 300 -e p:0:0 -m " & chr(34) & "Nightly restart of computer" & chr(34) & " \\" & strComputer
Set objShell = CreateObject("WScript.Shell") 
objShell.Run strShutdown, 0, False
 
Set objShell = Nothing
End sub

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:

Select allOpen in new window

 

by: pbest93Posted on 2009-04-06 at 10:55:22ID: 24079882

bluntTony,

that looks perfect, exactly what i was looking for.

thanks for taking time to explain it as well, i appreciate it.

let me double check it tonight before i award points and call it done, but nice work!

thanks,

josh

 

by: bluntTonyPosted on 2009-04-06 at 10:57:15ID: 24079901

If you want to first ping the machine quickly to check and make the script wait then the below code will do so. It's similar to jareds, but I've added a pause to wait for the objExec command to complete before deciding whether to shut it down, otherwise you might get a false negative on some machines.

Dim strRoot(2)
Dim strFilter, strAttrs, strScope, strDNSSuffix, strBase
Dim objConn, objRS, objShell,objExec
 
Set objShell = CreateObject("Wscript.Shell")
 
strRoot(0) = "OU=Member Servers,OU=Computers,OU=MyBusiness,DC=domain,DC=local"
strRoot(1) = "OU=Domain Controllers,DC=domain,DC=local"
strRoot(2) = "OU=Workstations,OU=Computers,OU=MyBusiness,DC=domain,DC=local"
 
strFilter = "(objectclass=computer);"
strAttrs  = "name;"
strScope  = "subtree"
 
strDNSSuffix = ".domain.local"
 
'This is your main loop, each time a different search base.
For i = 0 To UBound(strRoot) 
	strBase   =  "<LDAP://" & strRoot(i) & ">;"
	Set objConn = CreateObject("ADODB.Connection")
	objConn.Provider = "ADsDSOObject"
	objConn.Open "Active Directory Provider"
	Set objRS = objConn.Execute(strBase & strFilter & strAttrs & strScope)
 
	objRS.MoveFirst
	'This is your inner loop, each time an individual PC found in the search of the base.
	While Not objRS.EOF
		Set objExec = objShell.Exec("ping -n 2 -w 1000 " & objRS.Fields("name").Value & strDNSSuffix)
		Do Until objExec.Status
			WScript.Sleep 250
		Loop
		strOutput = LCase(objExec.StdOut.ReadAll)
		If InStr(strOutput,"ttl") > 0 Then ShutDownComputer(objRS.Fields("name").Value & strDNSSuffix)
		objRS.MoveNext
	Wend
	
	Set objConn = Nothing
	Set objRS = Nothing
	
Next 'i
 
 
Sub ShutDownComputer(byval strComputer)
Dim strShutDown,objShell
 
strShutDown = "C:\bin\restart_computers\psshutdown.exe -r -f -c -t 300 -e p:0:0 -m " & chr(34) & "Nightly restart of computer" & chr(34) & " \\" & strComputer
Set objShell = CreateObject("WScript.Shell") 
objShell.Run strShutdown, 0, False
 
Set objShell = Nothing
End sub

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:

Select allOpen in new window

 

by: bluntTonyPosted on 2009-04-06 at 10:59:40ID: 24079926

Actually I think I was a bit hasty - you should ping the machine quickly before issuing the shutdown command. If psshutdown is anything like shutdown.exe, it will hang for a good 10 secs before deciding it can't contact the machine so it'd be quicker to do the ping test first.... (sorry - my bad).

 

by: jared_lukerPosted on 2009-04-06 at 11:10:51ID: 24080035

Nicely done bluntTony... much cleaner...

I would disagree with you on the pinging though.  The script will run MUCH faster if you are pinging to check if the host is alive.  If you are starting the script before you go home and just walk away, then it's probably not an issue.  I usually start a script and watch it for a while to see if it's behaving.  I can't stand waiting for something to time out such as psshutdown.

If you just put ",true" at the end of the objShell.run line, it will make sure that only one psshutdown process is running at a time.  I prefer to do it that way.

 

by: bluntTonyPosted on 2009-04-06 at 11:37:59ID: 24080335

Yeah, I think our posts may have crossed :) I sort of come to that conclusion after posting and have had to backtrack. I think I need to have some sleep....

 

by: jared_lukerPosted on 2009-04-06 at 11:46:31ID: 24080407

For some strange reason, I'm getting  "Active Directory: An invalid directory pathname was passed"  AFTER it has echo'd all computers in the OU and sub-OU's.

Everything works fine except for that.

 

by: pbest93Posted on 2009-04-06 at 11:55:54ID: 24080511

unlike jared, mine worked ok one one machine in one ou, but then on another machine in another test ou, i got a different error (this is for bluntTony's script that pings first)

either bof or eof is true, or the current record has been deleted. requested operation requires a current record
code: 800a0bcd
(see attachment)

i am googleing it now

 

by: pbest93Posted on 2009-04-07 at 00:24:39ID: 24084573

ok, not sure what the difference was, but when i ran the script in a production ou, i didnt get the error.

i tested the script in a few different ways, and i attached what i came up with.

changes:
1. instead of useing the ping command to see if host was up, i used psshutdowns "-n" option for a timeout. with the ping command, the script took 9 minutes. with the "-n" option, it took 3 (both approximate times)
2. i reverted back to the pause every 10 records for 5 seconds tony. jared, i tried your suggestion of one instance of psshutdown, but that ran very, very slowly (even with the -n 1 option, it seemed to take 5 seconds per instance, which would have taken hours, unfortunately)

so, nice work, i will keep you posted if i find any more tweaks that seem to work better.

blunttony- excellent work, appreciate your help and explanations, i am giving you almost all the points
jared- thanks for your input, i think you would agree that tonys script is the answer, but i am giving some points to you for the input and help

thanks guys!

Dim strRoot(2)
Dim strFilter, strAttrs, strScope, strDNSSuffix, strBase
Dim objConn, objRS, objShell,objExec
 
Set objShell = CreateObject("Wscript.Shell")
 
strRoot(0) = "OU=test00,OU=Company,DC=domain,DC=local"
strRoot(1) = "OU=test01,OU=Company,DC=domain,DC=local"
strRoot(2) = "OU=test02,OU=Company,DC=domain,DC=local"
 
strFilter = "(objectclass=computer);"
strAttrs  = "name;"
strScope  = "subtree"
 
strDNSSuffix = ".domain.local"
 
'This is your main loop, each time a different search base.
For i = 0 To UBound(strRoot) 
	strBase   =  "<LDAP://" & strRoot(i) & ">;"
	Set objConn = CreateObject("ADODB.Connection")
	objConn.Provider = "ADsDSOObject"
	objConn.Open "Active Directory Provider"
	Set objRS = objConn.Execute(strBase & strFilter & strAttrs & strScope)
 
	objRS.MoveFirst
	'This is your inner loop, each time an individual PC found in the search of the base.
	While Not objRS.EOF
		'For every 10 records looped through. Pause for 5 secs.....
		If objRS.Bookmark Mod 10 = 0 Then
			WScript.Sleep 5000
		End If
		ShutDownComputer(objRS.Fields("name").Value & strDNSSuffix)
		objRS.MoveNext
	Wend
	
	Set objConn = Nothing
	Set objRS = Nothing
	
Next 'i
 
 
Sub ShutDownComputer(byval strComputer)
	Dim strShutDown,objShell
	' Control the timeout with the "-n" option instead of pinging
	strShutDown = "C:\bin\restart_computers\psshutdown.exe -r -f -c -t 300 -e p:0:0 -n 1 -m " & chr(34) & "Nightly restart of computer" & chr(34) & " \\" & strComputer
	Set objShell = CreateObject("WScript.Shell") 
	objShell.Run strShutdown, 0, FALSE
 
	Set objShell = Nothing
End Sub
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:

Select allOpen in new window

 

by: pbest93Posted on 2009-04-07 at 00:27:15ID: 31567098

thanks!

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...