问题
I have this running from my c# winforms app:
string ExecutableFilePath = @"Scripts.bat";
string Arguments = @"";
if (File.Exists(ExecutableFilePath )) {
System.Diagnostics.Process.Start(ExecutableFilePath , Arguments);
}
When that runs I get to see the cmd window until it finishes.
Is there a way to get that to run without showing it to the user?
回答1:
You should use ProcessStartInfo class and set the following properties
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);
}
来源:https://stackoverflow.com/questions/14225020/c-sharp-winforms-and-command-line-batch-files