Create an exe executable and hide the console window using C#

I needed to create an executable which would run as a job triggered from a scheduler. I decided to create a Console application, using, of course C#. I wanted it to run without the Console window popping up. I asked myself, how do I stop the console window from popping up or how do I hide the console window. It turns out there is a simple way to do this, however, searching the internet there are lots of tips using ProcessInfo or using PInvoke, they work but are not the best solution. The best solution I have found is to perform the following simple steps.

  • Right-click the console application project and select properties
  • Select the application (Anwendung) tab
  • Select Windows Application (Windows-Anwendung) from the Output Type (Ausgabetyp) dropdown

image

That is it. Run the console application and the window will not show up.