Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 03-31-2010, 02:54 AM   #1
Beta Member
 
Join Date: Mar 2010
Posts: 1
Default Programming to force shut down(Windows)

Hi, i want to make a program using C# which will force the shut down in windows. How can i do it? I have no idea about how the shut down works in windows.
__________________

sohel is offline   Reply With Quote
Old 04-01-2010, 03:40 PM   #2
j03
~~~~~~~~
 
Join Date: Jan 2005
Location: Wales
Posts: 5,556
Send a message via MSN to j03
Default Re: Programming to force shut down(Windows)

You can run:

shutdown -f -t 10 -s

to shutdown a computer running windows, so you could probably just run that as a system command.
__________________

j03 is offline   Reply With Quote
Old 04-01-2010, 11:06 PM   #3
Daemon Poster
 
winslow33's Avatar
 
Join Date: Jul 2009
Posts: 861
Default Re: Programming to force shut down(Windows)

better yet, just make a quick batch file and drop it on the desktop...
winslow33 is offline   Reply With Quote
Old 04-02-2010, 06:20 AM   #4
Site Team
 
berry120's Avatar
 
Join Date: Jul 2009
Location: England, UK
Posts: 3,425
Default Re: Programming to force shut down(Windows)

As above, I'd recommend just putting
Code:
shutdown -f -t 10 -s
into a batch file and running that. C# is absolutely overkill for this purpose!

The -f in the command is used to force shutdown (even if other programs aren't responding or try to hang.) The -s bit is the bit that's telling it to shut down and the -t 10 means do it in 10 seconds.
__________________
Save the whales, feed the hungry, free the mallocs.
berry120 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 11:06 AM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0