C#新建进程窗口不隐藏 [英] C# New process window does not hide
本文介绍了C#新建进程窗口不隐藏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能的重复:
隐藏 C# 应用程序中的命令窗口
在控制台应用程序中,我想运行 cmd 命令,但正在创建一个新窗口,为什么?
in the console app, I want to run the cmd command, but a new window is being created, why ?
Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.CreateNoWindow = true;
startInfo.UseShellExecute = false;
startInfo.FileName = "cmd.exe";
startInfo.WorkingDirectory = @"C:\m_f";
startInfo.Arguments = "/c START _creator.bat";
process.StartInfo = startInfo;
process.Start();
编辑
我不得不将一些代码更改为:
edit
I had to change some code to:
startInfo.FileName = @"C:\m_f\_creator.bat";
startInfo.WorkingDirectory = @"C:\m_f\";
startInfo.Arguments = "some_args";
现在可以了
推荐答案
start
生成一个新窗口,无论父 shell 是否有窗口.
start
spawns a new window, regardless of whether the parent shell has a window or not.
运行一个批处理文件cmd/c foo.cmd
就足够了,甚至foo.cmd
.
To run a batch file cmd /c foo.cmd
suffices, or even foo.cmd
.
这篇关于C#新建进程窗口不隐藏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文