苏飞论坛
标题:
C#调用CMD,隐藏窗口执行dos命令
[打印本页]
作者:
www.qq.com
时间:
2015-1-20 19:29
标题:
C#调用CMD,隐藏窗口执行dos命令
新手呢,这个就是我的Hello world .
(, 下载次数: 54)
上传
点击文件名下载附件
作者:
水手
时间:
2015-1-20 21:26
看过帖子回复一下是个好习惯
作者:
huangyouwei
时间:
2015-5-23 13:58
谢谢楼主辛苦了
作者:
912288184
时间:
2015-6-3 09:48
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.CreateNoWindow = true;
p.Start();
p.StandardInput.WriteLine("shutdown.exe -s -t 00");//完全关机模式 正常开始速度
p.StandardInput.WriteLine("exit");//退出dos命令
p.WaitForExit();
p.Close();
}else{
System.Diagnostics.Process bootProcess = new System.Diagnostics.Process();
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.CreateNoWindow = true;
p.Start();
p.StandardInput.WriteLine("shutdown.exe -s -hybrid -t 00");//龟息神功,开机速度一般6-20秒
p.StandardInput.WriteLine("exit");//退出dos命令
p.WaitForExit();
p.Close();
};
核心代码就是用了Process 这个类。
作者:
Chablis
时间:
2016-4-15 00:54
作者:
zx421001
时间:
2018-2-2 16:53
谢谢楼主辛苦了
作者:
poor_guy
时间:
2020-3-23 17:54
无法下载
欢迎光临 苏飞论坛 (http://www.sufeinet.com/)
Powered by Discuz! X3.4