如何运行可执行文件,但保持可执行文件的控制台隐藏在C#代码中? [英] How to run an executable file but keep the console of executable file hidden in C# code?
问题描述
我有一个可执行文件,我需要在C#代码中运行,但控制台应该在运行时隐藏。
下面是我使用的代码运行可执行文件:
------------------------------------ ----------------
流程流程=新流程();
process.StartInfo.FileName =。\ \ABC.exe;
process.Start();
---------------------------- ------------------------
请求您建议如何实现这一目标。
我尝试了什么:
流程流程=新流程();
process.StartInfo.FileName =.\\ ABC.exe;
process.Start();
I have an executable file which I need to run in a C# code but the console should be hidden while it is running.
Below is the code I used to run the executable file:
----------------------------------------------------
Process process = new Process();
process.StartInfo.FileName = ".\\ABC.exe";
process.Start();
----------------------------------------------------
Request you to please suggest how this can be achieved.
What I have tried:
Process process = new Process();
process.StartInfo.FileName = ".\\ABC.exe";
process.Start();
推荐答案
请看这里: ProcessStartInfo.CreateNoWindow Property(System.Diagnostics) [ ^ ]并阅读备注部分。
See here: ProcessStartInfo.CreateNoWindow Property (System.Diagnostics)[^] and read the "Remarks" section.
我只想出来并希望与所有人分享同一段代码:
流程流程=新Process();
process.StartInfo.FileName =.\\ ABC.exe;
process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
process.Start();
i just figured it out and would like to share the same piece of code with all:
Process process = new Process();
process.StartInfo.FileName = ".\\ABC.exe";
process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
process.Start();
这篇关于如何运行可执行文件,但保持可执行文件的控制台隐藏在C#代码中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!