C#Winforms和命令行批处理文件 [英] C# Winforms and command line batch files
本文介绍了C#Winforms和命令行批处理文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我从我的c#winforms应用程序中运行了此代码:
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);
}
运行该命令后,我将看到cmd窗口,直到完成为止.
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?
推荐答案
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);
}
这篇关于C#Winforms和命令行批处理文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文