solving sql server problems for millions of dbas and developers since 2006



SQL Server DBA Tips SQL Server Developer Tips SQL Server Business Intelligence Tips SQL Server Career Tips SQL Server Tip Categories SQL Server Tutorials SQL Server Webcasts SQL Server Whitepapers SQL Server Tools SQL Server Questions and Answers MSSQLTips Authors About MSSQLTips SQL Server User Groups MSSLQTips Giveaways MSSQLTips Advertising Options

MSSQLTips Facebook Page MSSQLTips LinkedIn Page MSSQLTips RSS Feed MSSQLTips Twitter Page MSSQLTips Google+ Page





Remotely Shutdown, Restart or Log Off the local or network computers

By: | Read Comments | Print

Jugal has 8+ years of extensive SQL Server experience and has worked on SQL Server 2000, 2005, 2008 and 2008 R2.

Related Tips: More

Problem

When installing a SQL Server cluster, Services Packs, Hotfixes, etc.. there may be a need to reboot both the nodes for changes to take affect and to reboot the server we have to login to each node which is time consuming. Also, there may be a time when you are not able to login to the server after a reboot due to the server being hung. In this tip we will take a look at the SHUTDOWN command and how it could be used.

Solution

This article will guide you through how to use the DOS SHUTDOWN command in Windows to remotely shutdown, restart or log off the local or network computer..

Shutdown command is useful for these scenarios:

1. In case we have to restart multiple computers
2. Server is pingable, but not allowing user to login, in that case we can restart the server remotely
3. User is able to login, but can see only a blue screen, so at that time we can remotely restart the computer

Permission

You must have administrative access to the local or network computer to restart it remotely. For multiple computers in the domain it is recommended to use the Domain Administrator account.

Command Syntax

Usage: shutdown [-i | -l | -s | -r | -a] [-f] [-m \\computername] [-t xx] [-c "comment"] [-d up:xx:yy]



-i
Show the graphical user interface of shutdown window
-l
To log off from the machine. Make sure that you are not using –l switch with –m switch
-s
Shutdown the desired computer
-r
Shutdown and restart the computer
-a
Abort a system shutdown
-m
-m\\machine name is used for to shutdown/restart/abort remote computer
-f
Forces running application to close without warning
-t
-t xx set timeout for shutdown command to xx seconds
-c
-c”comment” to add shutdown comment, you can add up to max 127 characters

You can also see above output by executing shutdown \? command from DOS

SHUTDOWN command using GUI
Go to -> Run -- Cmd -- type the shutdown –I command

Go to - Run -- Cmd -- type the shutdown –I command

Here you can select the different options (Restart/Shutdown/Log Off) as per your need. Click on Add… button to add the remote server name.

you can select the different options (Restart/Shutdown/Log Off) as per your need

Execute SHUTDOWN command using command prompt

Here I am restarting remote server (MSSSQLBOX) from the command prompt
shutdown –m \\mssqlbox –r
If you get an access denied/permission error, use the NET USE command
net use \\machine /USER:
shutdown -r -f -m \\machine name

Next Steps

  • Take some time to lear about the different switches
  • Create a batch file by adding a number of servers with the SHUTDOWN command
  • Execute shutdown command by using the time (-s,-t) and immediately execute the abort (-a) command


Related Tips: More | Become a paid author


Last Update: 5/17/2010

Share: Share 






Comments and Feedback:


Post a Comment or Question

Keep it clean and stay on the subject or we may delete your comment.
Your email address is not published. Required fields are marked with an asterisk (*)

*Name   *Email   Notify for updates
Comments
*Enter Code refresh code


 
New SQL Monitor v3.0

New SQL Monitor v3.0


Sponsor Information
Find and fix SQL Server problems before they happen - SQL diagnostic manager now with predictive analysis!

Time-strapped database professionals use SQL Monitor to look after their servers. Try it online.

Need SQL Server help and not sure where to turn? Reach out to expert consultants for a Health Check.

Find and Fix SQL issues with Foglight Performance Analysis. Get a free copy.

Join the over million SQL Server Professionals who get their issues resolved daily.

Demystify TempDB Performance and Manageability


Copyright (c) 2006-2012 Edgewood Solutions, LLC All rights reserved
privacy | disclaimer | copyright | advertise | about
authors | contribute | feedback | giveaways | user groups
Some names and products listed are the registered trademarks of their respective owners.


Edgewood Solutions LLC | MSSharePointTips.com | MSSQLTips.com