C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Operating System »

Shutting Down , Restarting or Logging Off Computer in a Simple Way


Posted Date: 09 Apr 2009    Resource Type: Code Snippets    Category: Operating System
Author: Hefin DsouzaMember Level: Diamond    
Rating: 1 out of 5Points: 10



The following codes will be helpfull for Shuting Down , Restarting or Logging Off Current System from a .Net Application.

Shuting Down
C# - Remember to add Using System.Diagnostics
Then in any Event Handler Enter

Process.Start("shutdown.exe","-s"); // By Default the Shutdown will take place after 30 Seconds if you want to change the Delay try this one
//Process.Start("shutdown.exe","-s -t xx"); //Replace xx with Seconds example 10,20 etc


VB.Net - Remember to add Imports System.Diagnostics
Then in any Event Handler Enter

Process.Start("shutdown.exe","-s")' By Default the Shutdown will take place after 30 Seconds if you want to change the Delay try this one
'Process.Start("shutdown.exe","-s -t xx")'Replace xx with Seconds example 10,20 etc

Restarting Computer
C# - Remember to add Using System.Diagnostics
Then in any Event Handler Enter

Process.Start("shutdown.exe","-r"); // By Default the Restart will take place after 30 Seconds if you want to change the Delay try this one
//Process.Start("shutdown.exe","-r -t xx"); //Replace xx with Seconds example 10,20 etc


VB.Net - Remember to add Imports System.Diagnostics
Then in any Event Handler Enter

Process.Start("shutdown.exe","-r")' By Default the Restart will take place after 30 Seconds if you want to change the Delay try this one
'Process.Start("shutdown.exe","-r -t xx")'Replace xx with Seconds example 10,20 etc

Logging Off
C# - Remember to add Using System.Diagnostics
Then in any Event Handler Enter

Process.Start("shutdown.exe","-l"); //This Code Will Directly Log Off the System Without warnings


VB.Net - Remember to add Imports System.Diagnostics
Then in any Event Handler Enter

Process.Start("shutdown.exe","-l")'This Code Will Directly Log Off the System Without warnings


This Code Can Be Used in Both Console As Well As Windows Application

If you face any problems simply post a response.
Regards
Hefin Dsouza



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Shutdow  .  Restart  .  Log Off  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: c# code to format system culture information
Previous Resource: Getting System Information
Return to Discussion Resource Index
Post New Resource
Category: Operating System


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use