我从c#winforms app开始运行:
string ExecutableFilePath = @"Scripts.bat";
string Arguments = @"";
if (File.Exists(ExecutableFilePath )) {
System.Diagnostics.Process.Start(ExecutableFilePath , Arguments);
}
当它运行时,我会看到cmd窗口,直到它完成。
有没有办法让它在没有向用户显示的情况下运行?
答案 0 :(得分:8)
您应该使用ProcessStartInfo类并设置以下属性
string ExecutableFilePath = @"Scripts.bat";
string Arguments = @"";
if (File.Exists(ExecutableFilePath ))
{
ProcessStartInfo psi = new ProcessStartInfo(ExecutableFilePath , Arguments);
psi.UseShellExecute = false;
psi.CreateNoWindow = true;
Process.Start(psi);
}