C# 打开、运行exe文件的三种方式
方法一:
System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo(path);
info.WorkingDirectory = Path.GetDirectoryName(path);
System.Diagnostics.Process.Start(info);
方法二:
System.Diagnostics.Process.Start(path)
方法三:
string path = @"F:\2\"; //文件所在目录
string filename = "a.exe";//文件名
System.Diagnostics.Process p = new System.Diagnostics.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.StartInfo.WorkingDirectory = path;
p.Start();
p.StandardInput.WriteLine(filename);
p.StandardInput.WriteLine("exit");
System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo(path);
info.WorkingDirectory = Path.GetDirectoryName(path);
System.Diagnostics.Process.Start(info);
方法二:
System.Diagnostics.Process.Start(path)
方法三:
string path = @"F:\2\"; //文件所在目录
string filename = "a.exe";//文件名
System.Diagnostics.Process p = new System.Diagnostics.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.StartInfo.WorkingDirectory = path;
p.Start();
p.StandardInput.WriteLine(filename);
p.StandardInput.WriteLine("exit");
中国· 上海
添加微信咨询
CopyRight©2009-2019 上海谷谷网络科技有限公司 All Rights Reserved. 沪ICP备11022482号-8
- top
- 在线咨询
-
添加微信咨询