码迷,mamicode.com
首页 > Windows程序 > 详细

C# 执行外部命令的代码

时间:2019-05-04 18:47:47      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:关于   cmd   shel   star   public   art   start   timeout   comm   

下面代码内容是关于C# 执行外部命令的代码,应该对大家有用。

 public static int executeCommand(string cmd, int millsecTimeOut) {
    System.Diagnostics.ProcessStartInfo processStartInfo = 
       new System.Diagnostics.ProcessStartInfo("CMD.exe", "/C "+cmd);
    processStartInfo.CreateNoWindow = true;
    processStartInfo.UseShellExecute = false;
    System.Diagnostics.Process process = 
       System.Diagnostics.Process.Start(processStartInfo);
    int exitCode = process.ExitCode;
    process.Close();
    return exitCode;
 }

C# 执行外部命令的代码

标签:关于   cmd   shel   star   public   art   start   timeout   comm   

原文地址:https://blog.51cto.com/14314834/2388692

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!