文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>.Net程序操作CMD命令

.Net程序操作CMD命令

时间:2011-04-12  来源:NatureSex

 使用代码操作CMD命令行程序
public void CloseComputer(string cmd)
{
            Process p = new Process();
            p.StartInfo.FileName = "cmd.exe";
            p.StartInfo.UseShellExecute = false;
            p.StartInfo.RedirectStandardInput = true;
            p.StartInfo.RedirectStandardOutput = true;
            p.StartInfo.RedirectStandardError = true;
            p.StartInfo.CreateNoWindow = true;
            p.Start();
            //设置自动刷新缓冲并更新
            p.StandardInput.AutoFlush = true;
            //写入命令
            p.StandardInput.WriteLine(cmd);
            p.StandardInput.WriteLine("exit");
            //等待结束
            p.WaitForExit();
            p.Close();
 }


OK!有了这个就可以执行一些C#不能操作的内容啦.................
相关阅读 更多 +
排行榜 更多 +
步行僵尸2无限金币版

步行僵尸2无限金币版

体育竞技 下载
狐狸一号特殊任务无限金币版

狐狸一号特殊任务无限金币版

体育竞技 下载
忍者之雷复仇无限金币钻石版

忍者之雷复仇无限金币钻石版

体育竞技 下载