View Full Version : Bat File Blues
powellm
04-12-2005, 10:39 AM
Hey Guys,
I've been doing a little bit of .bat scripting here in the Underground, and I've hit a bit of a snag. I need to write a file that will monitor the system time and reboot at a certain hour. I know how to determine the time, and how to reboot, but monitoring constantly and triggering at the appropriate hour are eluding me. Any suggestions?
powellm
04-12-2005, 10:42 AM
Followup:
My solution doesn't necessarily have to be a .bat file, but it needs to be deployable through group policy.
dparm
04-12-2005, 11:16 AM
It is possible to force a reboot or logoff when the GP updates. Here are some of the optional switches for the "Gpupdate" command.
/Logoff. causes user to logoff after GP refresh
/Boot. causes reboot after GP refresh
powellm
04-12-2005, 11:24 AM
I want it to reboot everyday at a set time, so I dont think that solution will work.
dparm
04-12-2005, 12:30 PM
Could Ghost or DeepFreeze be configured to do this? I get the feeling that you cannot really force a restart at a set time every day without some sort of 3rd party software.
dparm
04-12-2005, 12:32 PM
I found this:
http://www.computerhope.com/shutdown.htm
Dunno if it helps, but it does explain the syntax of the "shutdown" command.
powellm
04-12-2005, 01:44 PM
I've got the syntax down for "shutdown." The problem is how to trigger it at the appropriate time. As for Ghost and DeepFreeze, the machines have neither. Any idea if theres a way to add tasks to the windows scheduler remotely?
dparm
04-12-2005, 03:21 PM
Not sure, let me do some research tomorrow when I'm in.
fturtle
04-12-2005, 05:44 PM
I'd suggest using the "Scheduled Tasks" utility in Windows.
Windows XP doesn't have a sleep program/command for use in batch files, unless you install the Windows Server 2003 Resource Kit (http://www.microsoft.com/downloads/details.aspx?FamilyID=9d467a69-57ff-4ae7-96ee-b18c4790cffd&DisplayLang=en). That means your loop wouldn't have any delay (insane) unless you acquired this (or another) sleep program that can wait a certain amount of seconds.
With "Scheduled Tasks" (in control panel) you can just set Windows to run a program (or batch file, or other file) every day at your specified time, etc. The batch file would have nothing but the shutdown command.
It'd be possible to set up a looping batch with the sleep program the kit provides, but it'd be more practical to use "Scheduled Tasks," since this is what it's supposed to do.
jharriso
04-12-2005, 07:12 PM
Use PStools with the following command executed at startup.
psshutdown -2300 for, say, 11:00 PM
http://www.sysinternals.com/ntw2k/freeware/pstools.shtml
Muy useful toys.
fturtle
04-12-2005, 07:33 PM
Nice, even better.
dparm
04-12-2005, 09:25 PM
SysInternals comes through again!
powellm
04-12-2005, 11:25 PM
But once again, is it deployable through group policy?
vBulletin® v3.8.2, Copyright ©2000-2009, Jelsoft Enterprises Ltd.