0

I created app that open every time that I start pc. So its so annoying to close it every time so I'm wondering if its some code that will hide my console app. I saw videos and tutorials on forms but idk how to do it with console app.

uafa
  • 1
  • You need to write a Windows Service.https://learn.microsoft.com/en-us/dotnet/framework/windows-services/walkthrough-creating-a-windows-service-application-in-the-component-designer – Andrew Shepherd Dec 10 '20 at 22:54

2 Answers2

0

Option 1

You can use this run command:

start /min "SomeTitle" MyConsoleApp.exe myarg1 myarg2

Thus it will be on the taskbar minimized.

Option 2

If you use a file link in the start menu, select the start minimized option for the exe.

Option 3

Using a WinForm app you will be able to use a tray icon by setting the main form as not visible, to say it simply because it can be complex according to the expected behavior, and it will not be in the taskbar too.

Option 4

If you don't want a main form, create a win form app, delete the form file and the code in the main method, and you're done, without GUI nor console, no main input and no main output but you can show MessageBox and some forms when necessary, just a background process only visible in the Task Manager.

With that you can add a tray icon to to offer exit and some status information for example.

Option 5

Also you can create a windows service:

.NET console application as Windows service

Note

In all cases, if you don't use an internal message events dispatcher like the WinForms Application pattern or WPF and so on, be carefull to not saturate the CPU with the processings like with loops and use Thread.Sleep() between iterations or any thread idleing pattern or some timer if necessary.

0

The easiest way to do this is change your console app to a windows app.

Console apps get a console made for them by Windows. But if you change it to a windows forms app, then windows expect the application to make a window, so if you never make a window, then it will never show

The other way is to turn your application into a service. This has some additional requirements in terms of programming

Keith Nicholas
  • 43,549
  • 15
  • 93
  • 156
  • I don't think windows app that does not start message loop early will be treated nicely when "run at startup"... To my limited knowledge there are a lot of requirements for such apps to not be blocked next time... – Alexei Levenkov Dec 10 '20 at 23:18
  • 1
    @AlexeiLevenkov its fine, I've used it quite a bit before, however I tend to write things as services these days – Keith Nicholas Dec 10 '20 at 23:22