2014.10.1 Cmd更改系统时间

Process p = new Process();

//Process类有一个StartInfo属性

//设定程序名

p.StartInfo.FileName = "cmd.exe";

////设定程式执行参数   “/C”表示执行完命令后马上退出

p.StartInfo.Arguments = string.Format("/c date {0} time {1}",date,time);

////关闭Shell的使用 

p.StartInfo.UseShellExecute = false;

////重定向标准输入    

p.StartInfo.RedirectStandardInput = true;

p.StartInfo.RedirectStandardOutput = true;

////重定向错误输出 

p.StartInfo.RedirectStandardError = true;

////设置不显示doc窗口

p.StartInfo.CreateNoWindow = true;

////启动

p.Start();

////从输出流取得命令执行结果

return p.StandardOutput.ReadToEnd();

posted on 2016-10-15 17:01  mol1995  阅读(380)  评论(0编辑  收藏  举报

导航