Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

Remote restart - resolved


  • Please log in to reply

#1
samiko

samiko

    Retired Staff

  • Retired Staff
  • 424 posts
hello

I am just wondering if there is a way of restarting a group of Windows XP Pro workstations remotely using Windows 2003 server?
is there some kind of a script that can target RPC service?

thanks in advance...

Edited by samiko, 22 September 2006 - 09:22 AM.

  • 0

Advertisements


#2
Spike

Spike

    nOoB

  • Member
  • PipPipPipPip
  • 1,357 posts
Hey there samiko, I havnt really worked on Windows 2003 but try this command.

Open "Run" console and type in:

"shutdown -i"

This should work...

Let me know if this is what you were looking for...

Are you the administrator of the computers???

Cool :whistling:
  • 0

#3
samiko

samiko

    Retired Staff

  • Topic Starter
  • Retired Staff
  • 424 posts
Hi Spike

Thanks for the quick reply, I am the domain admin on our network. I have designed an MSI package which I would like to install via GPO's, but I want to schedule these machines to restart at a certain time.

shutdown command only works per machine, I was thinking more like a policy or a script that can restart a group of machines.

thanks
  • 0

#4
Spike

Spike

    nOoB

  • Member
  • PipPipPipPip
  • 1,357 posts
No problem... Well how about you wright a script and put it on the machines manually instead of doing it remotly. Or how about a remote admin tool.

I can write you the script or find you the remote tool.

Just let me know. Cool :whistling:
  • 0

#5
samiko

samiko

    Retired Staff

  • Topic Starter
  • Retired Staff
  • 424 posts
I would be happy to know both options for personal reference.
  • 0

#6
Spike

Spike

    nOoB

  • Member
  • PipPipPipPip
  • 1,357 posts
Ok, does the script have to be anything specific or can I write it in VB?

I will get you that remote tool now.

Cool :whistling:
  • 0

#7
samiko

samiko

    Retired Staff

  • Topic Starter
  • Retired Staff
  • 424 posts
nothing specific about the script, I can change it if I need to.
  • 0

#8
Spike

Spike

    nOoB

  • Member
  • PipPipPipPip
  • 1,357 posts
Ok samiko, here is the script:

Dim oFSO, oTS, sClient, oWindows, oLocator, oConnection, oSys
Dim sUser, sPassword

sUser = "Administrator"
sPassword = "password"

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oTS = oFSO.OpenTextFile("C:\clients.txt")

Do Until oTS.AtEndOfStream
 
 sClient = oTS.ReadLine
 
 Set oLocator = CreateObject("WbemScripting.SWbemLocator")

 Set oConnection = oLocator.ConnectServer(sClient, _
   "root\cimv2", sUser, sPassword)

 Set oWindows = oConnection.ExecQuery("Select " & _
   "Name From Win32_OperatingSystem")
 For Each oSys In oWindows
   oSys.Win32ShutDown(5)
 Next

Loop

oTS.Close
WScript.Echo "Done!"

Line 4: sUser = "Administrator" Administrator user name
Line 5: sPassword = "password" Administrator password
Line 8: Set oTS = oFSO.OpenTextFile("C:\clients.txt") Text File with users that you want to shutdown
Line 21: oSys.Win32ShutDown(6) Where you see "6" is the code number for shutdown command

Shutdown Command:

4 = Force logoff
5 = Force shutdown
6 = Force rebooot
12 = Force power off

Copy the code and paste it into notepad remeber to save the extension as ".vbs"

Try out this code, because all the program I have found are not free so I guess this is the best thing to do. Let me know what you think. Cool :whistling:
  • 0

#9
samiko

samiko

    Retired Staff

  • Topic Starter
  • Retired Staff
  • 424 posts
thanks Spike very much appreciated.
I will give this a go ...
  • 0

#10
samiko

samiko

    Retired Staff

  • Topic Starter
  • Retired Staff
  • 424 posts
can anyone tell me what's wrong with the following code??

Const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile ("c:\clients.txt", ForReading)

strText = objTextFile.ReadAll
objTextFile.Close

arrComputers = Split(strText, vbCrLf)

For Each strComputer in arrComputers
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

Next


Thanks in advance
  • 0

#11
Spike

Spike

    nOoB

  • Member
  • PipPipPipPip
  • 1,357 posts
Hey again samiko.

I don't see anything wrong with this code... Why, what is the problem?

Cool :whistling:
  • 0

#12
samiko

samiko

    Retired Staff

  • Topic Starter
  • Retired Staff
  • 424 posts
its coming up with an error message when trying to run it, the error is:

script: c:\restart.vbs
line: 13
char: 1
Error: the remote server machine does not exist or is unavailable:'GetObject'
Code: 800A01CE
Source: Microsoft VBScript runtime error

the machine is on the network and I can use the script to restart the machine if I specify it in the script.
  • 0

#13
Spike

Spike

    nOoB

  • Member
  • PipPipPipPip
  • 1,357 posts
It worked on my machine but I was looking through it again and I just changed the script a bit because of this:

line: 13
char: 1


Const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile ("c:\clients.txt", ForReading)

strText = objTextFile.ReadAll
objTextFile.Close

arrComputers = Split(strText, vbCrLf)

For Each strComputer in arrComputers
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

Next

As you can see all I did was remove "_", sounds like it couldnt read the characters... Did my script not work? But I still can't see anything wrong with this script, looks good to me. I'll do some more searching.

Cool :whistling:
  • 0

#14
samiko

samiko

    Retired Staff

  • Topic Starter
  • Retired Staff
  • 424 posts
well i thought to do a little bit of research just to avoid putting the domain admin username and password.
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP