Is there a way to hide the console window when executing a console application?
I am currently using a Windows Forms application to start a console process, but I don't want the console window to be displayed while the task is running.
Is there a way to hide the console window when executing a console application?
I am currently using a Windows Forms application to start a console process, but I don't want the console window to be displayed while the task is running.
Simple answer is that: Go to your console app's properties(project's properties).In the "Application" tab, just change the "Output type" to "Windows Application". That's all.
You can use the FreeConsole API to detach the console from the process :
(of course this is applicable only if you have access to the console application's source code)
Add this to your class to import the DLL file:
And then if you want to hide it use this command:
And if you want to show the console:
If you are using Process Class then you can write
before
yourprocess.start();
and process will be hiddenBased on Adam Markowitz's answer above, following worked for me:
If you're interested in the output, you can use this function:
It runs the given command line program, waits for it to finish and returns the output as string.