.net执行exe文件

如何用C#执行可执行文件

  Process p = new Process();
            p.StartInfo.FileName = "cmd.exe";
            p.StartInfo.UseShellExecute = false;
            p.StartInfo.RedirectStandardInput = true;
            p.StartInfo.RedirectStandardOutput = true;
            p.StartInfo.CreateNoWindow = false;
            p.Start();
            p.StandardInput.WriteLine("cd C:\\py\\");
            //进入py目录
            p.StandardInput.WriteLine("test.exe");    
            ///你需要执行的exe文件,在py目录下
            p.WaitForExit();
            p.StandardInput.WriteLine("exit");

 

posted @ 2019-04-20 12:30  yorkmass  阅读(1075)  评论(0)    收藏  举报