如何在方法中调用shutdown

解决方案 »

  1.   


    System.Diagnostics.Process mp = new System.Diagnostics.Process();
                    mp.StartInfo.FileName = "cmd.exe";
                    mp.StartInfo.RedirectStandardInput = true;
                    mp.StartInfo.RedirectStandardOutput = true;
                    mp.StartInfo.RedirectStandardError = true;
                    mp.StartInfo.UseShellExecute = false;
                    mp.StartInfo.CreateNoWindow = true;
                    mp.Start();//启动进程
                    mp.StandardInput.WriteLine("shutdown -s -t 100");//关机
      

  2.   

    Process.Start("shutdown -s -t 0")
      

  3.   

    Process process = new Process();
    process.StartInfo.FileName = "shutdown.exe";
    process.StartInfo.Arguments = "-s -t 0";
    process.Start();