c# 执行exe

以下是代码:

Process process = new Process();
string exePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,  "a.exe");

string s = "";
foreach (var tmpArg in args)
{
	s += tmpArg.ToString() + " ";
}
s = s.Trim();
if (string.IsNullOrWhiteSpace(s))
{
	throw new Exception("缺少参数");
}

ProcessStartInfo psi = new ProcessStartInfo(exePath , s)
{
	CreateNoWindow = true,
	UseShellExecute = false,
};
process.StartInfo = psi;

process.Start();
process.WaitForExit();

发表评论

邮箱地址不会被公开。 必填项已用*标注