我从我的 c# winforms 应用程序运行这个:
string ExecutableFilePath = @"Scripts.bat";
string Arguments = @"";
if (File.Exists(ExecutableFilePath )) {
System.Diagnostics.Process.Start(ExecutableFilePath , Arguments);
}
当它运行时,我会看到 cmd 窗口,直到它完成。
有没有办法让它在不向用户显示的情况下运行?
最佳答案
你应该使用 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);
}
关于C# Winforms 和命令行批处理文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14225020/