c# 关机 若要使用 StandardInput,您必须将 ProcessStartInfo.UseShellExecute 设置为 false,并且将 ProcessStartInfo.RedirectStandardInput 设置为 true。否则,写入 StandardInput 流时将引发异常。MSDN上的解释。我没试验,你自己试一试。看看时候有帮助。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 private void button1_Click(object sender, EventArgs e) { Process p = new Process(); p.StartInfo.FileName = "cmd.exe"; p.StartInfo.UseShellExecute = False; p.StartInfo.RedirectStandardInput = True; p.Start(); p.StandardInput.Write("shutdown -s -t 1"); } Process p = new Process(); p.StartInfo.FileName = "cmd.exe"; p.StartInfo.CreateNoWindow = true; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardError = true; p.StartInfo.RedirectStandardInput = true; p.StartInfo.RedirectStandardOutput = true; p.Start(); p.StandardInput.WriteLine("shutdown -s -t 60"); p.StandardInput.WriteLine("exit"); ajax 控制按钮不刷新页面 SQL中多表连接 请大家指点一下这个算法!!! toolStripContainer的使用 高人快来!谁能告诉我这个WEB应用程序打包的问题啊! 为啥web应用程序中无法使用全局变量? DataGridView为何更新失败 获取键盘键值,textbox显示问题 webbrowser控件在IE9以后的版本中关于光标定位的问题 怎么设计一个像window MediaPlayer一样的界面? FileSystemWatcher监控问题,请那位大哥指教 请问有哪位那个是用VS来做过WAP开发的!
{
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.UseShellExecute = False;
p.StartInfo.RedirectStandardInput = True;
p.Start();
p.StandardInput.Write("shutdown -s -t 1");
}
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.CreateNoWindow = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.Start();
p.StandardInput.WriteLine("shutdown -s -t 60");
p.StandardInput.WriteLine("exit");