SaphuA SaphuA - 1 year ago 121
C# Question

Hide main form C# on autorun

I found a realy simple method online that allows me to hide the main form in my application:

  • Create a console application

  • Set output type to Windows Forms Applications

This works perfectly when I run the application either from debugging in visual studio or manually.


I have also set this application to auto start with windows (Windows 7 in this case), so I don't have to start it manually every time. When this happens there is a very very very short moment in which I can still see a full screen form blink. Is there a way I can prevent this from happening?

Edit: People seem to missing one important thing.
The project is created as a Console Application, so it has no Form or Application.Run() method. It just has a single static Main method like any other Console Application.

Edit2: Just out of interest, should I rather make a normal WinForms project and try to hide that Main window using either a suggested answer or other sollution?


Answer Source

what you are probably seeing is the command window appear and disappear.

I would recommend creating it either as a form and then following what Jeffery suggested or create and install it as a service that starts each time.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download