Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  Advanced Search 


February 2005

PsShutdown

Make remote shutdowns a cinch
RSS
Subscribe to Windows IT Pro | See More Windows NT 4.0 Articles Here | Reprints
Or get the Monthly Online Pass—only $5.95 a month!

Eventually, all of us who manage computer networks need to reboot multiple computers as part of a maintenance task. The Windows Server 2003 or Windows XP Shutdown command and the Shutdown utility from the Microsoft Windows 2000 Server Resource Kit provide basic functionality but often fall short when dealing with shutdown variations on multiple remote computers. Sysinternals' PsShutdown, one of the tools in Sysinternals' free PsTools utility suite, offers more flexibility and power than the Microsoft Shutdown tools do. Plus, PsShutdown works on Windows NT 4.0 and later, although some options require Win2K or later. (See "Make Remote Shutdowns a Snap," January 2005, InstantDoc ID 44710 for another custom shutdown tool.)

Basic Options
PsShutdown is a command-line tool that works on local and remote systems. You don't need to install software on any remote systems against which you want to run the tool.

Figure 1 shows PsShutdown's syntax, which requires at least one argument specifying the type of shutdown you want to perform. This requirement prevents you from accidentally initiating a shutdown of the local system. Table 1 lists the types of shutdown that the tool supports. As you can see, PsShutdown offers power management—related options in addition to a standard shutdown or reboot. If one of these shutdown options is the only argument you specify, PsShutdown displays the dialog box that Figure 2 shows, then performs the specified operation after a default timeout of 20 seconds.

Shutdown, poweroff, and reboot actions typically give applications a chance to abort a shutdown. For example, if a Microsoft Word document that contains unsaved changes is open on a user's system, Word asks the user whether he or she wants to save the file before Word exits. After a default period of 5 seconds (as specified in the HKEY_CURRENT_USER\CONTROL PANEL\Desktop\HungAppTimeout registry entry), Windows displays a dialog box that offers the user the option to cancel the shutdown or to exit the application and continue the shutdown process. By default, Windows displays this dialog box indefinitely, but you can use PsShutdown's -f switch to force open applications to close even when they contain unsaved data.

When you perform shutdown operations (especially on remote systems), you might want to inform active users of the reason for the shutdown, or perhaps even give them longer than the default time to save their work and log off. You can use PsShutdown's -m switch, followed by a message within quotation marks ("), to add a message at the bottom of the tool's shutdown-notification dialog box. You can use the tool's -t switch to override the default timeout value. You can specify a timeout in seconds or, if you want PsShutdown to perform the operation at a particular time, you can specify that time by using a 24-hour notation. The following sample command will reboot the local system at 10 p.m. and will let users know the reason for the reboot.

psshutdown -m "The system requires a reboot to 
  complete hotfix installation" -t 22:00 -r

If you're concerned that some users might find the shutdown inconvenient and you want to give them the option of aborting it, use PsShutdown's -c switch to add a Cancel button to the notification dialog box. If you want to cancel an entire shutdown operation that you've already launched but that hasn't yet taken place, you can use the -a switch to abort the operation.

Lock and Logoff
In addition to standard shutdown operations, PsShutdown supports two desktop management—related operations: lock and logoff. You've probably used Group Policy to configure a default idle timeout after which your network's desktop systems lock automatically. However, if you step away from a system without manually locking it and want to ensure—without waiting for the default timeout and without having to physically return to the system—that the system is locked immediately, PsShutdown's -l switch, which immediately locks the specified system, can be helpful.

PsShutdown's logoff option is arguably more useful than its lock option. Some per-user Group Policy and application settings refresh during the logon process. Therefore, you might want to forcibly log off any users that remain logged on after hours. You can use the -o switch to log off system console users.

Target Systems
PsShutdown, like most of the utilities in PsTools, offers several ways for you to identify the computer or computers on which you want it to operate. Run the command without specifying a computer name to have PsShutdown control the local system, or specify a remote system (e.g., comp1) by including a double slash (\\) followed by the computer name, as in the following sample:

psshutdown -r \\comp1

You can include multiple computers by using the following syntax:

\\comp1,comp2,comp3

You can also use an asterisk (*) to target all systems in the current domain:

\\*

If you find yourself often needing to perform shutdown operations on a particular group of computers, you can include those system names in a text file, then specify the filename, after the @ symbol, in the PsShutdown command. For example, the command to reboot systems specified in a file named complist.txt would be

psshutdown -r @complist.txt

In the text file, place the name of each computer, without the leading double slash, on a separate line.

If you try to use PsShutdown to control a computer that's already off, the command might appear to hang for a minute before timing out. This delay, which is the standard Windows timeout for computer connections, can severely lengthen shutdown operations that run against many computers. To shorten the length of time that PsShutdown will attempt to establish a connection before giving up, use the -n switch followed by the desired timeout, specified in seconds.

Inside PsShutdown
PsShutdown shares its remote-access capabilities with several other members of the PsTools suite, including PsExec. PsShutdown extracts a Windows service executable to the system that it will control through that system's Admin$ share, starts the service, then sends the service a command that reflects the options you've specified. The service uninstalls after it completes the command. Therefore, you must enable file sharing on any remote computers on which you want to use PsShutdown, and the Admin$ share (which is defined by default) must be defined and accessible through the Common Internet File System (CIFS)/Server Message Block (SMB) and Remote Procedure Call (RPC) TCP/IP ports. The account from which you run PsShutdown must have Administrative group membership on all target systems, or you must use the tool's -u switch to specify an account that has the necessary permissions.

Free Download
You can download PsShutdown by going to http://www.sysinternals.com and downloading the PsTools suite. For more information about some of the other tools in the suite, see "PsList and PsKill," September 2004, InstantDoc ID 43569, and "PsExec," July 2004, InstantDoc ID 42919.

End of Article



Reader Comments
Just looking for away to do this thanks

lazybum714 May 12, 2008 (Article Rating: )


You must log on before posting a comment.

If you don't have a username & password, please register now.




Top Viewed ArticlesView all articles
VMware and the Future of Virtualization

What's next for virtualization and business IT? Windows IT Pro senior editor Jeff James speaks with VMware President and CEO Diane Greene on the future of virtualization technology. ...

The Memory-Optimization Hoax

Don't believe the hype. At best, RAM optimizers have no effect. At worst, they seriously degrade performance. ...

What service packs and fixes are available?

...


Windows OSs Whitepapers Replay for Exchange: Enterprise Protection and an Affordable Price

Are You Satisfied?

A Preliminary Look at Deployment Plans for Microsoft Windows Vista

Related Events Check out our list of Free Email Newsletters!

Windows OSs eBooks Understanding and Leveraging Code Signing Technologies

A Guide to Windows Disaster Recovery and Backup

A Guide to Windows Certification and Public Keys

Related Windows OSs Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.


ADS BY GOOGLE SPONSORED LINKS FEATURED LINKS

Critical Challenges of ESI & Email Retention
Are you storing too much electronic information? Get expert legal advice and better understanding of what you are required to do as an IT professional.

Become a fan of Windows IT Pro on Facebook!
Join us on Facebook and be a fan of Windows IT Pro!

Sustainable Compliance: Are You Having a Resource Crisis?
Read this white paper to examine trends in compliance and security management and review approaches to reducing the cost and operational burden of compliance.

Rev Up Your IT Know-How with Our Recharged Magazine!
The improved Windows IT Pro provides trusted IT content with an enhanced new look and functionality! Get comprehensive coverage of industry topics, expert advice, and real-world solutions—PLUS access to over 10,000 articles online. Order today!

Get It All with Windows IT Pro VIP
Stock your IT toolbox with every solution ever printed in Windows IT Pro and SQL Server Magazine plus bonus Web-exclusive content on hot topics. Subscribe to receive the VIP CD and a subscription to your choice of Windows IT Pro or SQL Server Magazine!



Order Your Fundamentals CD Today!
Gain an introduction to Exchange, learn server security requirements, and understand how unified communications can play a role in your messaging strategies with this free Exchange CD.
Windows IT Pro Home Register About Us Affiliates / Licensing Media Kit Contact Us/Customer Service  
SQL Connected Home IT Library SuperSite FAQ Wininfo News
Europe Edition Office & SharePoint Pro Windows Dev Pro Windows Excavator 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2008 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing