Using .NET and C#.NET, We can perform Shut Down, Restart and Log off operation on current PC.
In .NET Framework we have a namespace Using System.Diagnostics which has the required class and methods to perform these operations from a .NET application running on a current PC.
Please Use the below buttons to perform Shutdown, Restart and Logoff on Current PC.
diagnostics.aspx.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | //SHUT DOWN protected void btnShutDown_Click(object sender, EventArgs e) { 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 } //RESTART protected void btnRestart_Click(object sender, EventArgs e) { 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 10"); //Replace xx with Seconds example 10,20 etc } // LOG OFF protected void btnLogOff_Click(object sender, EventArgs e) { Process.Start("shutdown.exe", "-l"); //This Code Will Directly Log Off the System Without warnings } |
Tags: ASP.NET, C#, Logoff, Restart, shutdown, System.Diagnostics