Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatic/forced restart

Status
Not open for further replies.

maddogmick

Technical User
Oct 25, 2005
10
US
Hi all.
We are running windows 2003 server (sbs) and i would like to make all the workstations automatically re start at midnight or a set time is there a way that i can force workstations to re start every night?
they all run windows XP Pro.
The reason is that if i go round and re boot every pc we dont get problems with quick books but if i dont after a few days it falls over, this is a known issue with quick books and they know about it and dont have a answer to it.
(useless i think they call it) anyway is ther a way to force from the server a re boot for all work stations (5)?
thanks in advance

Mick

TeamEiE.jpg
 
Here you go. Create a text file with the names of your five workstations in it, one name per line. Save tghe following code to a text file and give it a VBS extension. Schedule this to run on your server in scheduled tasks at whatever time you want the PCs to reboot.

You could locally schedule to run Shutdown.exe on the workstations or use the same WMI code in the script below locally, but then you have to do the work 5 times. I think it is cleaner to have it run from the server.

Code:
'==========================================================================
'
' NAME: RebootWSfromList.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: [URL unfurl="true"]http://www.thespidersparlor.com[/URL]
' 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

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
By the way, I like your little Watching you graphic. I know how to grab all of the info you are grabbing, but how do you dump it into a PNG file programatically?

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
Hey Mark thank you, i understand i think!
I save the script that you have given me as a text file but change it to something like shutdown.vbs then list all the 5 computers on a separate txt file i have one per line.Then run task in scheduled tasks, i asume it will ask me where the file i want to run is located or does it matter where i load the file to? and do they have to be in the same folder(i guess)
will this shut them down or re boot them (would like to reboot them) its just that after 7 years the people that work in the office still cant cut and paste! yeah i know imagine trying to explain that it was me that shut the pc's down they can just handle putting in there passwords!!!
thanks again
the watching you watching me png i have had for years and years lol you can make it at dansoft.com (i cant take the credit for it) wish i was that clever!
Just out of interest if you are in NY or near go to my web site (im going to visit your tommorrow at work) we are having a raffle for a trip to Glamis california (you will get what its all about when you get there!)

Mick


TeamEiE.jpg
 
ok got it i read it again this morning and see that sorry didnt get to read it till very late last night!

Thanks again

Mick

TeamEiE.jpg
 
Hi Mark sorry but it doesnt work, let me just run by what i did as it might be me if thats ok?
I took the script that you gave me and saved it as a text file then gave it a .VBS ext in the server, I saved it in a directory i made for it called "reboot" in the same directory i saved a txt file called "WSLIST.TXT" with the computers (workstations ) names, i then set this in the scheduler to start daily Mon-Fri 11.59pm and it didnt work
I tried clicking on the VBS file to make it ask me for a computer name or ip address and it didnt do anything.

any ideas am i missing something so simple
thanks

Mick

TeamEiE.jpg
 
Sorry for the delay in response. My ISP just delivered 19 messages that are 11 days old! So I didn't see notification for this threads activity.

Test it out manually and lets see what errors you may get if you comment out the On Error Resume Next line. Insert a ' at the beginning of the line to comment it out.

Test with just a single workstation name in the file. Run the script and it should reboot the workstation.

Make sure that the ID you use has rights on the remote box and make sure that the Windows Firewall isn't blocking your access too.



I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
Mick, have you solved this problem?

Hope this Helps.

Neil J Cotton
njc Information Systems
Systems Consultant
 
No sorry Neil I havent yet!
I now have a very slow desktop that takes like 5 minutes for anythiong to appear or work, I have all the internet connections and intranet as well everyone can log on but everything is so slow, i have re booted and nothing changes, i have posted in the forum but no answer in a week.
not much i can do until i can sort this out sorry Neil will get back toy ou unless you can answer this one for me lol

thanks
Mick

TeamEiE.jpg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top