Click here to Skip to main content
15,890,506 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all
I wanna make a program in vb.net about shuting the computer down by click on a button.
can any one please tell me the codes for shut down,restart,sleep,lock,hibernate andd log off the computer.
i wanna just the code for shutting down note the code of the program
thanks
Posted

One way is simple: use the application "shutdown.exe" and start it with System.Diagnostics.Process.Start. Another method is using WMI.

See:
http://stackoverflow.com/questions/1215139/reboot-machine-from-a-c-wpf-app[^],
http://www.geekpedia.com/code36_Shut-down-system-using-Csharp.html[^].

—SA
 
Share this answer
 
v2
Comments
[no name] 23-Jun-11 14:36pm    
i didn't understand the way very much
i mean i want code like this
System.Diagnostics.Process.Start("Shutdown", "/s /f /t 00")
Sergey Alexandrovich Kryukov 23-Jun-11 14:38pm    
What is the sense of your statement? Please explain.
Does it solve your problem?

If it works for you, please formally accept the solution (green button).
Thank you.
--SA
[no name] 23-Jun-11 14:42pm    
no it didn't work because i didn't understand it
can you please explain it more
Sergey Alexandrovich Kryukov 23-Jun-11 15:00pm    
What exactly you don't understand? How to use Process.Start? What it does? What is "shutdown.exe"? It's all described in first link. I just don't know what else to explain.
--SA
fjdiewornncalwe 24-Jun-11 15:17pm    
Agreed and +5. But if he wants the user to be able to shut the machine down on a button click, why doesn't the user just press the power button on the case??? :)
try this

http://users.telenet.be/jbosman/applications.html
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900