Matthew ".NET 247" Reynolds

Matthew Reynolds... software development consultant, author, speaker and trainer

Shutdown command (via Rob McLaws)

This morning, on the drive to work I was thinking about some code I had to write today that had to shut down the PC after it had finished.  Aware that I could use ExitWindowsEx to the job, I wasn't relishing - as I never do - declaring said method so that I could call it from managed code.

What do I discover when I refresh SharpReader this morning?  Rob McLaws points me in the direction of a Windows command line command that can restart, shutdown and otherwise screw with any computer on the network.  So, now I have an option - either call ExitWindowsEx, or give Process.Start an instruction to run “shutdown”.

What's amazing to me about this is it brings home just how damn useful blogs actually are as a learning experience, and how timely information that comes over this media can be.  I was thinking about a problem, and lo and behold there I am instantly in touch with someone who's thinking about a solution to my problem from an entirely different perspective. 

Updated: As far as I can tell, not supported on anything other than XP and Win2K3.

Comments

William Bartholomew said:

I'm assuming similar functionality is also available through WMI allowing you to stick to managed code and not suffer the possibly unreliability of calling out to a command-line process.
# August 29, 2003 2:31 AM

Robert McLaws said:

Glad I could help :).
# August 29, 2003 2:56 AM

Phil Weber said:

"As far as I can tell, not supported on anything other than XP and Win2K3."

Matthew: SHUTDOWN.EXE was originally provided in the Resource Kits for NT4 and Win2K Server (http://www.ss64.com/nt/shutdown.html) It's now included in the standard installation of XP and 2K3.
# August 29, 2003 5:35 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)