C#电脑自动关机代码指令

时间:2016-11-08 13:36:17   收藏:0   阅读:167

      Process p = new Process();//实例化一个独立进程
                p.StartInfo.FileName = "cmd.exe";//进程打开的文件为Cmd
                p.StartInfo.UseShellExecute = false;//是否启动系统外壳选否
                p.StartInfo.RedirectStandardInput = true;//这是是否从StandardInput输入
                p.StartInfo.CreateNoWindow = true;//这里是启动程序是否显示窗体
                p.Start();//启动
                p.StandardInput.WriteLine("shutdown -s -t 1");//运行关机命令shutdown (-s)是关机 (-t)是延迟的时间 这里用秒计算 10就是10秒后关机
                p.StandardInput.WriteLine("exit");

原文:http://www.cnblogs.com/wyt007/p/6042426.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!