Shutdown computer using C# | C# Code to Shutdown Computer
In this article, learn how to perform shutdown through simple C# code. By writing few lines of code you can create an executable that shutdown your computer with a single click.
Shutdown Computer using C# code:
using System; using System.Diagnostics; namespace ConsoleApplication1 { public class Program { public static void Main() { ShutDown(); } ////// Function to shutdown the computer. /// public static void ShutDown() { Process.Start("shutdown", "/s /t 0"); } ////// Function to perform silent computer shutdown. /// public static void ShutDown2() { var process = new ProcessStartInfo("shutdown", "/s /t 0"); process.CreateNoWindow = true; process.UseShellExecute = false; Process.Start(process); } } }
using System; using System.Diagnostics; namespace ConsoleApplication1 { public class Program { public static void Main() { ShutDown(); } ////// Function to perform silent computer shutdown. /// public static void ShutDown() { var process = new ProcessStartInfo("shutdown", "/s /t 0"); process.CreateNoWindow = true; process.UseShellExecute = false; Process.Start(process); } } }
– Article ends here –