Solved

RebootAll_ST is not working

Posted on 2006-07-14
2
138 Views
Last Modified: 2010-04-23
I am not a programmer.  I have the task of doing remote reboots of all the workstations in my domain and needed a tool that would work simply for me.  I downloaded your tool and I believe I edited the script properly but the tool runs and doesn't rebbot any of the workstations in the OU.  I need to be ready for this tomorrow as we have scheduled a Domain rename.  This is of course Windows 2K3 AD.  There is nothing in the log file either.  There were no instructions as to exactly how to edit the vb script files.

Can you help???  
0
Comment
Question by:heqarota
2 Comments
 
LVL 41

Accepted Solution

by:
graye earned 500 total points
ID: 17107911
Hummm... RebootAll_ST isn't a vb script.  It's Visual Basic .Net 2003 source code.

That means that you (or someone in your organization) will have to use Microsoft Visual Studio to compile the source code into a usable program that will run on your computer.  Luckily, Microsoft provides the Visual Basic 2005 Express Edition as a free download at http://msdn.microsoft.com/vstudio/express/vb

After compiling, you just edit the *.config file (with notepad or any other text editor) to change the parameters to suit your needs.  The parameters are fairly straight forward:

DOMAIN - The name of your AD domain
OU - a "filter" (if required) that limits the scope to a particular OU
FILTER - a "name filter" (if required) to select only PCs that match a pattern
EXCEPTION_LIST - the path to an text file that contains a list of PCs (one per line) to exclude
LOG_FILE - the path to a file that will contain the log of what's happening
LOG_LEVEL - How much detail goes in the log
LIST_METHOD - for you, it'd be "AD_Doman"

If you need a VBScript version, here is something that will do almost the same thing as the RebootAll_ST program.  It will require some editing to meet your needs (server, share, and domain names)

Dim objs, obj
Dim wsh, Cmd, i, buf, ComputerName
dim fso, ts, exclude(100), skip, list
dim MyName

' get a list of PCs that you want to exclude
set fso = createobject("Scripting.FileSystemObject")
list = 0
if fso.fileexists("\\SomeServer\SomeShare\Reboot_Exceptions.txt") then
      set ts = fso.OpenTextFile("\\SomeServer\SomeShare\Reboot_Exceptions.txt", 1)
      do while not ts.atendofstream
            exclude(list) = ts.readline
            list = list +1
      loop
end if

' find out our computer name (we don't want to reboot ourselves!)
' let's make sure this is one of our PCs!
Set objs = GetObject("winmgmts:").InstancesOf("Win32_ComputerSystem")
for each obj in objs
      myname = obj.name
      exit for
next

' execute the "Net View" command
Set wsh = CreateObject("WScript.Shell")
set Cmd = wsh.Exec("Net View /Domain:YourDomain")
wscript.sleep 1000

' read the output and parse the computer names
do while Not Cmd.StdOut.AtEndOfStream
      buf = cmd.stdout.readline
      if left(buf, 2) = "\\" then
            i = instr(buf, " ")
            ComputerName = mid(buf, 3, i-3)
            ' check to see if we should exclude this PC
            skip = false
            for i = 0 to list -1
                  if ucase(computername) = ucase(exclude(i)) then
                        skip = true
                        exit for
                  end if
            next
            ' make sure to skip me!
            if computername = myname then
                  skip = true
            end if
            if not skip then
                  reboot computername
            end if
      end if
loop

sub reboot(computername)
      ' ignore errors (already logged off, not Win2k, etc)
      on error resume next
      Set objs = GetObject("WinMgmts://" & computername & "/root/cimv2").InstancesOf("Win32_OperatingSystem")
      for each obj in objs
            obj.Win32ShutDown(6)
      next
      set objs = nothing
      on error goto 0
end sub
0
 

Author Comment

by:heqarota
ID: 17109477
Thanks so much for your help.  As I said before, I'm no programmer and have'nt touched any code in years.  I think both solutions are excellent.  I have downloaded VB and am attempting to compile the code now.  

Thanks again
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now