«

»

Print this Post

Shutdown Computers from Command Line

SHUTDOWN Notification in Windows 8

SHUTDOWN Notification in Windows 8

I was recently surprised by how many seasoned IT Pros didn’t know that they had the ability to shut down a server or workstation from the command line using the SHUTDOWN command. Not only is it possible to shut down the local machine from the command line, but it is also possible to shutdown other machines on your domain as well.

Why is this important?

This is useful in many ways. Utilizing the command line shutdown routine, you can now script shutdowns or reboots of systems. If you have ever run Exchange or SQL, then you know they will take as much memory as possible to use as cache. While this makes your SQL or Exchange server perform better, the only way to get these systems to release memory is by rebooting. By using the SHUTDOWN command from the command line you can choose when to reboot your servers to reduce user downtime.

I have used this method many times to gracefully shutdown hung servers. As I’m sure you’re aware, shutting down a server gracefully is always preferable to taking it down hard by holding in the power button for 10 seconds. Taking a DC (domain controller) or SQL server down hard oftentimes leads to corruption (which sometimes isn’t noticed until years later).

How does it work?

First launch an administrative command prompt. For instructions on launching an administrative command prompt see my prior post titled How to Open the Command Prompt in Windows 7/Vista with Administrative Rights. From an administrative command prompt you have several combinations (type SHUTDOWN /? to see all options for the SHUTDOWN command). Here are a few examples to get you started:

The following will reboot the server with a five minute fuse. The “/R” switch indicates a reboot instead of a shutdown. The “/T” switch indicates the time in seconds until the reboot. When this line is executed all users with a desktop session on this system will get a notification that the server will shutdown. On some systems users will even get a countdown showing how long they have until the system is restarted.
SHUTDOWN /R /T 300

The following command will shutdown the server immediately. The “/S” switch indicates you wish to shutdown the server instead of rebooting. The “/T 0” switch indicates time in seconds. Since zero seconds is indicated, the system will process the shutdown immediately.
SHUTDOWN /S /T 0

This example will reboot a server on the network named SERVER1. The “/F” switch will force the shutdown regardless of any open applications or services. This is often helpful for hung or stubborn servers. The “/M \\SERVER1” switch indicates which remote machine will execute the command (in this case SERVER1).
SHUTDOWN /F /R /M \\SERVER1 /T 0

About the author

Robert Borges

About Robert...

I have been in the IT industry since 1993 focusing mainly in networking. Though I got an early start as an amateur computer enthusiast, and wrote my first database app at age 12, I started my professional career working in the MIS department of one of the largest liquor distributors in the northeast. I started out there as a systems operator on the company’s two mainframe systems. From there I moved into PC support, and help design and implement the company’s first client-server network… This was back in the days of Win NT 3.51. I also worked on my first migration to NT 4.0 back then.

From there I went on to work with Novell 3.x and 4.x along with Windows domains and active directory environments. Working my way up from technician, to specialist, to administrator, and eventually all the way up to Sr. Engineer. I spent many years working for consulting firms, 9 of which I owned and operated my own firm.
Over the years, I have worked with (at an expert level) various versions of: Windows client and server operating systems (including Windows 7 and Windows Server 2008 R2);various virtualization technologies (Hyper-V, Virtual Server, Virtual PC, VMware, etc…); MS-SQL server 6.5- 2008 R2; Exchange 4-2010, and much more.

I am now Director of Information Systems at Bay State Integrated Technology focusing on cloud computing and IT service, with expertise in: IT Infrastructure & Architecture, IT Security, and Cloud Computing platforms & technologies (SaaS, PaaS, and IaaS).

I am in a constant state of learning about new products, and new versions of products. Many of which we end up implementing in lab environments and sometimes for our clients. I have a pretty broad range of expertise and experience. It is my goal to share some of this experience on this blog to help enrich the IT community.

Permanent link to this article: http://www.robertborges.us/2013/07/windows/shutdown-computers-from-command-line/

Leave a Reply