Windows 2003 Remote Shutdown Script

Tony Giangreco
Tony Giangreco used Ask the Experts™
on
We have three servers in or network (1-2008, 2-2003). The UPS software that performs the automated shutdown in case of a power failure didn't work quick enough yesterday when we had a power outage. I was not there to manually shut them down and two went down hard before the UPS shutdown completed.

I have a restart script that use for remote maintenance and just modified it for shutdown instead of restart. I've put it on the server 2008 desktop for the office mgr to use incase of an emergency. Now I'd like to create a script she can execute to manually shutdown the two other servers.

Here is a quick script that runs on the 2008 server.

cd\
net stop "AeLookupSvc" /y
net stop "AppHostSvc" /y
net stop "QuickBooksDB20" /y
net stop "QBCFMonitorService" /y
net stop "Spooler" /y
....
shutdown /s /t /30 /f /d /p:4:1

I have a shutdown file very simular to this on the two 2003 servers in the domain. How do I automate the remote shutdown of both of them from the 2008 server properly?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Gerwin Jansen, EE MVETopic Advisor
Most Valuable Expert 2016
Commented:
The shutdown command has options to shutdown a remote machine. As long as the user who is performing the actions on the 2008 server has rights on the 2003 server, this will work just fine. In case the user on the 2008 server does not have the rights, you have to add appropriate rights on the 2003 servers for it to work.

Author

Commented:
Yes, I know that. Looking at the script above, what is the syntax to shutdown server #2 and #3 from Server #1?
Top Expert 2011
Commented:
Hello,

You can use shutdown -i command to shutdown remote computer. However it required to have permission on remote server to shut it down.

Thanks,
Sanjay Santoki
11/26 Forrester Webinar: Savings for Enterprise

How can your organization benefit from savings just by replacing your legacy backup solutions with Acronis' #CyberProtection? Join Forrester's Joe Branca and Ryan Davis from Acronis live as they explain how you can too.

Commented:
If the servers are in domain, you can use the sc command to control services in others server

Your script could be like this

sc \\server2 "AeLookupSvc" stop
sc \\server2 "AppHostSvc" stop
....
shutdown \\server2 /s /t 30 /f /d /p:4:1

Commented:
sorry, i missed a parameter in shutdown

sc \\server2 "AeLookupSvc" stop
sc \\server2 "AppHostSvc" stop
....
shutdown /m \\server2 /s /t 30 /f /d /p:4:1

Commented:
sorry, another error, I should sleep a little more today...
sc uses server command service syntax

sc \\server2 stop "AeLookupSvc"
sc \\server2 stop "AppHostSvc"
....
shutdown /m \\server2 /s /t 30 /f /d /p:4:1

Commented:
if your server aren't in a domain, you can use psexec command using username and pass for the destination server.

the script could be like this

psexec \\server2 -u server2\username - p password net stop "AeLookupSvc" /y
psexec \\server2 -u server2\username - p password net stop "AppHostSvc" /y
psexec \\server2 -u server2\username - p password net stop "QuickBooksDB20" /y
psexec \\server2 -u server2\username - p password net stop "QBCFMonitorService" /y
psexec \\server2 -u server2\username - p password net stop "Spooler" /y
....
psexec \\server2 -u server2\username - p password shutdown /s /t 30 /f /d /p:4:1

Author

Commented:
Hi serchlop,

I will schedule network downtime next week and try this out. I need to be onsite to manually the servers back on.

Commented:
If your servers support wake on lan, you can use free wolcmd tool to start them remotely, you should enable in routers or communication hardware.

Author

Commented:
I tried this on Friday but had problems with the syntax. My maintenance window closed. I will try again this week.

Commented:
Ok, I use the following command to wake up a server in my company

Syntax
WolCmd.exe MAC IP NetworkMask PortWakeOnLAN

in another power on server I run

WolCmd.exe 001111222233 10.0.1.17 255.255.255.0 7

change 001111222233 for your MAC Address for your NIC in server you want to start
change 10.0.1.17 for the ip for your server

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial