Wednesday, May 14, 2008

Wake up and go to sleep!

.
At a recent CMRLS Techie Roundtable, Sal Genovese, Director at the Marlborough Public Library, demonstrated his implementation of Wake-on-LAN in his library. Wake-on-LAN (WOL or WoL) is an Ethernet computer networking standard that allows a computer to be turned on remotely by a network message. In Marlborough, staff arrives each morning to find all their PCs started up and ready to go, sparing them daily trek to every corner of the building to press all those on/off buttons. Using the Magic Packets WoL utility, all the computers receive a "wake up" command from a single PC, on a schedule that accommodates for the varying hours and days that the library is open. To find out more about setting up WoL in your library, see Sal's presentation at http://www.cmrls.org/pdf_documents/ce_materials/Wake-on-LAN.pdf, and download Magic Packets from http://www.cmrls.org/downloads/wol/magic_pkt.zip.

The ensuing roundtable discussion quickly turned to the obvious question: If I can automatically turn on my computers in the morning, can I also make them shut down at the end of the day? Indeed, this can be accomplished using Windows Task Scheduler and the shutdown.exe command. Here's how:

First, experiment at the command prompt (Start > Run > cmd) to determine the appropriate "arguments" for shutdown. The relevant parameters are

-s Shutdown the computer
-t xx Set timeout for shutdown to xx seconds
-c "comment" Shutdown comment (maximum of 127 characters)
-f Forces running applications to close without warning

A typical shutdown command might look like this:

shutdown -s -t 300 -c "The library closes at 5:00 PM." -f

The resultant shutdown window will display a message warning the user to save any work, a countdown timer showing time remaining before shutdown, and your own message (comment). When the specified time has elapsed, Windows will close any running programs (whether or not work has been saved) and initiate the shutdown process. NOTE: Since you don't want to actually shut the computer down during this testing, be sure to leave the command prompt window open; at any time during the countdown, type shutdown -a to cancel the operation.

Once you're satisfied with the command line you have fashioned, incorporate it into a batch file:
- Start Windows Notepad (Start > All Programs > Accessories > Notepad).
- Type the command exactly as you had at the command prompt.
- Save the file with a .bat extension. Important: Notepad normally saves files as text (.txt). To override this behavior, enclose the full file name and extension in double quotes when saving, e.g, "shutdown.bat" .
- Test the batch file by double-clicking it. Don't forget to have the command prompt window open to cancel the shutdown.)

With your working batch file saved to disk, use the Task Scheduler to run it at the appropriate time(s):
- Go to Control Panel
- Double-click Scheduled Tasks
- Double-click Add Scheduled Task
- Step through the Wizard to point to your batch file and select the days and times as required.
You can create multiple tasks to account for varying library hours. For example, one task may be set to run at 4:50 PM on Mondays, Wednesdays and Fridays, another at 6:50 PM on Tuesdays and Thursdays. Alternatively, you can create multiple schedules within the same task: Double-click the task for editing; on the Schedule tab, click "Show multiple schedules," then click "New."

Important: When you create a task, you will be prompted for a user account under which the task will run. This account must be a member of the Administrators group, and it must not have a blank password. The Scheduler will warn you if the user is not an administrator; however, it will accept a blank password, but it just won't run.

Note too that unlike the wakeup feature, your shutdown schedule will have to be set up separately on each computer in the library. While the shutdown utility does allow for one computer to issue the shutdown command to multiple PCs, configuring your network to allow such an operation is quite time consuming, not to mention fraught with unrelated perils.


Questions? Need help? Contact Rick Levine at CMRLS (rlevine@cmrls.org, x308)