View Full Version : forcing xp and 2k to reboot at a scheduled time
Mongoose
11-11-2004, 12:40 PM
i have about 200 machines that i would like to reboot every night at say midnight. they are all 2k/xp, i have login scripts and group policy control over all of them (windows AD).
i would really prefer to not have to touch every computer and put a task to do this in the scheduler as it would take forever. on xp you can use "shutdown -r -t 0" and on 2k i believe sysinternals has a free "reboot" util, but how do you get it on all of these machines?
has anyone scripted this or a similar scheduled task?
dbwillis
11-11-2004, 02:06 PM
From an NT Resource Kit you can use ShutGUI.exe to reboot or shut down local or remote PC's.
Im sure you can script it to reboot remote PC's via a txt listing of PC names....
Mongoose
11-11-2004, 02:09 PM
that is one option i've thought of. in the past i havent had much luck with using remote tools such as that though, and as most of these computers are winxp sp2 with the firewall enabled, im not sure how well that would work. thanks for the idea
bigstusexy
11-11-2004, 02:38 PM
Quick question how are you administering computers with the firewall turned on?
Secondly you can search for programs what will restart computers I think there is one called shutdown.exe from MS thats included with XP and 2k server I think. You can write a script that will shutdown and restart the computer, the just schedual that tast torun once a day at the specified time.
Fark_Maniac
11-11-2004, 02:43 PM
on a machine that has administrative rights on all of them, create a batch file like:
shutdown -m \\machine1 -r
shutdown -m \\machine2 -r
then use task scheduler to kick off the batch file at a specified time.
the only vice to this is you need to know every machine's name to create the batch file.
spectrum
11-11-2004, 02:47 PM
If you are running 2K3 server you can use the built in shutdown command and set up a batch file to read computer names from a text file. Then use the cmd schedular to run that script at a specified time.
Example:
Put the netbios names of the systems you want to reboot in a text file (ie c:\shutdownfile.txt) 1 name per line
System1
System2
System3
Now make a batch file like the following (ie c:\remotereboot.bat)
for /F %%i in (c:\shutdownfile.txt) do @echo shutdown -r -t 30 -c "nightly reboot" -m \\%%i
Now use the at command from a command prompt to schedule the job to run every night
at 12:00 AM /EVERY:su,m,t,w,th,f,sa "c:\remotereboot.bat"
for more info on the commands and their switches you can do the following from a command prompt:
shutdown /?
help at
help for
As far as SP2 and Windows firewall, you can push policies to it via GPO's to allow you to do remote desktop open ports etc. but that is whole 'nother thread :cool:
Edit:
You can right click an AD container and export the contents to a tab delimited file. Easy to extract just computer names from one of those.
Ranma_Sao
11-11-2004, 03:33 PM
To make this process easier, shutdown does work with IP's. But why do you want them to reboot every night at midnight?
Mongoose
11-11-2004, 05:00 PM
wow, first of all, thanks for all the great responses, i really appreciate the feedback
Quick question how are you administering computers with the firewall turned on?
Secondly you can search for programs what will restart computers I think there is one called shutdown.exe from MS thats included with XP and 2k server I think. You can write a script that will shutdown and restart the computer, the just schedual that tast torun once a day at the specified time.
login scripts and group policy are not affected by the firewall.
i know how to get the computers to shutdown, so thats not a problem. scheduling the shutdown on each computer is.
i'd really rather have each computer shut itself down as i have not had good luck getting computers to respond to remote commands in the past, and we get about 50 machine replacements every 6 months or so, so the list would be changing constantly.
is there a way anyone knows of to create a batch file that will install a scheduled event on the computer it is run on? if so i can put that in the login script for these machines and that would take care of the problem.
these machines are in a school of dentistry's clinics, and have 2 people logging into them each day (2 out of 420 students). these students generally do not log off when they are done, and the ones that do just log off rather than restarting the machines, this leads to 60 day uptimes. i get called all the time on problems that are solved with a reboot.
in one other area i have taken away the ability to simply log off or shutdown so they are forced to reboot, but in these areas they sometimes need to be able to log off quickly and have someone else log in immediately, so taking that away would be a poor choice. forcing the machines to reboot nightly right before my sus automatic updates are run seems like the logical way to proceed. thanks!
Fark_Maniac
11-11-2004, 06:06 PM
wow, first of all, thanks for all the great responses, i really appreciate the feedback
login scripts and group policy are not affected by the firewall.
i know how to get the computers to shutdown, so thats not a problem. scheduling the shutdown on each computer is.
i'd really rather have each computer shut itself down as i have not had good luck getting computers to respond to remote commands in the past, and we get about 50 machine replacements every 6 months or so, so the list would be changing constantly.
is there a way anyone knows of to create a batch file that will install a scheduled event on the computer it is run on? if so i can put that in the login script for these machines and that would take care of the problem.
these machines are in a school of dentistry's clinics, and have 2 people logging into them each day (2 out of 420 students). these students generally do not log off when they are done, and the ones that do just log off rather than restarting the machines, this leads to 60 day uptimes. i get called all the time on problems that are solved with a reboot.
in one other area i have taken away the ability to simply log off or shutdown so they are forced to reboot, but in these areas they sometimes need to be able to log off quickly and have someone else log in immediately, so taking that away would be a poor choice. forcing the machines to reboot nightly right before my sus automatic updates are run seems like the logical way to proceed. thanks!
you will not need to schedule a reboot on every machine...if you create the one batchfile to send reboot commands to every computer, you will only need to schedule one computer to send the commands.
Ranma_Sao
11-11-2004, 06:44 PM
I don't understand the problem from the description. 60 day uptimes is bad? However you can do the batchfile thing from the domain controller, heaven forbid someone is actually working on something important at midnight when you reboot the box out from under them.
chinoquezada
11-11-2004, 09:13 PM
This is what i use when i want to restart/shutdown... I don think it leaves a big footprint in your memory though... Might wanna try it.
http://www.driverheaven.net/showthread.php?s=&threadid=55058
bigstusexy
11-12-2004, 12:18 AM
I'm not sure anything but local programs will work if you use the firewall. I'm thinkng that the firewall would block SMB tottally so most of you control over a system would be lost, I could be wrong but thats what I'm thinking.
spectrum
11-12-2004, 10:09 AM
From the DC or any other machine where you are logged in as domain admin you can set scheduled tasks on other machines.
C:\>at /?
The AT command schedules commands and programs to run on a computer at
a specified time and date. The Schedule service must be running to use
the AT command.
AT [\\computername] [ [id] [/DELETE] | /DELETE [/YES]]
AT [\\computername] time [/INTERACTIVE]
[ /EVERY:date[,...] | /NEXT:date[,...]] "command"
\\computername Specifies a remote computer. Commands are scheduled on the
local computer if this parameter is omitted.
id Is an identification number assigned to a scheduled
command.
/delete Cancels a scheduled command. If id is omitted, all the
scheduled commands on the computer are canceled.
/yes Used with cancel all jobs command when no further
confirmation is desired.
time Specifies the time when command is to run.
/interactive Allows the job to interact with the desktop of the user
who is logged on at the time the job runs.
/every:date[,...] Runs the command on each specified day(s) of the week or
month. If date is omitted, the current day of the month
is assumed.
/next:date[,...] Runs the specified command on the next occurrence of the
day (for example, next Thursday). If date is omitted, the
current day of the month is assumed.
"command" Is the Windows NT command, or batch program to be run.
Specifically what you are looking for is the \\computername option
That sets the scheduled command to run on that computer. You could push this out 1X to each machine and from that point on each machine would take care of itself.
If logging people out is what you are looking for you could set logon restrictions in a GPO or user profile to deny logon from say 2300 to 0100 and select the "Force logout when time expires" option. I may have the option name wrong, but I know it can be done.
@ BigStu - it depends on how you have your domain GPO configured for the firewall. You config it so it allows smb from any computer on the network, only specific IP addresses/ranges etc.
Recomended reading:
http://www.microsoft.com/technet/security/prodtech/winclnt/secwinxp/xpsgapa.mspx
http://www.microsoft.com/downloads/details.aspx?FamilyID=cb307a1d-2f97-4e63-a581-bf25685b4c43&displaylang=en
Mongoose
11-12-2004, 10:47 AM
again thanks for all your thoughts.
i really dont want to have a remote computer rebooting these things, thanks for the suggestion but i dont want to do that.
the firewall is not an issue, ive been running for 6 months with the firewall in place (sp1 firewall before sp2), SMB is blocked but not needed anyway, almost everything you need to do (-this) can be done through group policy. you can also configure the firewalls (through group policy) to allow SMB if you want.
spectrum: thanks so much, that was exactally what i was looking for, using that i can create a login script:
AT \\%COMPUTERNAME% 23:59 /EVERY:Daily shutdown.exe -r -t 0
then after each machine logs in it will schedule the task. thanks a bunch man, and thanks to everyone for their suggestions
spectrum
11-12-2004, 11:04 AM
Anytime ;)
Ranma_Sao
11-12-2004, 03:32 PM
Do the users have the permission to schedule tasks for system? I hope not, since you are asking for a security nightmare.
streetkid
11-12-2004, 08:11 PM
Do the users have the permission to schedule tasks for system? I hope not, since you are asking for a security nightmare.
hehe
bigstusexy
11-12-2004, 09:14 PM
I just have never worked with the windows firewall in a situation where your peers or serverare outside of it.
I would like to take this time to say spectrum (http://www.hardforum.com/member.php?u=83663) vbmenu_register("postmenu_1026856543", true); thank you, Thank you very very much. You have just simplified my job next week as I went to inspect and find out just what was in one of your links :)
vBulletin® v3.8.2, Copyright ©2000-2009, Jelsoft Enterprises Ltd.