\[Editor's note: Email your scripting solutions (400 words or less) to R2R at email@example.com. Please include your script and phone number. We'll edit submissions for style, grammar, and length. If we print your contribution, you'll get $100.\]
Sometimes after I install new software or change computer settings on servers running Microsoft Exchange Server 5.0 or 5.5 with Service Pack 1 (SP1), the servers take a long time to restart. To reduce the startup times, I use the restart.bat script in Listing 1. With this script, the restart time is three times faster. The script improves the startup time because it stops the Exchange services.
Here's how the restart.bat script works. The script begins by cautioning users who are connected to the server that the server will reboot in 5 minutes. The script then uses the Net Stop command via the Exchange System Attendant service (msexchangesa) to stop the following Exchange services:
- Exchange Directory
- Exchange Event Service
- Internet Mail Service (IMS)
- Information Store (IS)
- Message Transfer Agent (MTA)
The list of services to stop might vary on different Exchange servers, depending on their configuration. The last line of the batch file uses the Microsoft Windows NT Server 4.0 Resource Kit's Shutdown utility to shut down the Exchange server after a 300-second delay and then restart it.
You use the Shutdown utility with several switches. The /c switch forces all running applications to quit without saving their data. The /l switch specifies a local shutdown. The /r switch specifies that the computer must reboot after it shuts down. The /t switch sets the timer for system shutdown. The default is 20 seconds.
To use this script, you need to replace ServerName with your server's name. You also need to replace Path with the path to your Shutdown utility.