+92 332 4229 857 99ProjectIdeas@Gmail.com

Shutdown,LogOff and Restart Commands(C#.net)


Shutdown , LogOff and Restart Commands :
The following code shows you how you can send shutdown, logoff and restart commands to the computer.



Code

using System.Diagnostics;

public void action(string str)
    {
            switch (str)
            {
                case "LogOff":
                    Process.Start("shutdown", "-l -f -t 0");
                        break;
                case "ShutDown":
                        Process.Start("shutdown", "-s -f -t 0");
                        break;
                case "Restart":
                        Process.Start("shutdown", "-r -f -t 0");
                        break;
                default:
                    break;
            }
   }


0 comments: