Search code examples
c#.netwinformstaskbarsystem-tray

What can I do to automatically run a windows form application at windows startup? And remove its icon from taskbar after minimizing to tray?


I have two questions:

  1. I'm trying to develop a windows forms application using C# in Visual Studio. I want my application to automatically start as soon as users start their computer. How do I achieve this?

  2. I'm using the notifyIcon control to minimize my application the systen tray. It works perfectly, but the icon from the taskbar remains as it is. I want it to be like uTorrent or BitTorrent, where minimizing the application sends it to the system tray and removes its icon from the taskbar.

I'm using .NET Framework 4.5.


Solution

  • You have a few options for running your Windows Form at startup.

    1. You can use the Windows Task Scheduler to run the program at startup. In your bin/Release or bin/Debug, get the scheduler to run your MyFormName.exe program when Windows starts. How-To Geek has a pretty good tutorial on how to do this.

    2. You could also use the Windows Startup folder. Make a shortcut to the If you want it to run for just the current user, the path to the folder is

      C:\Users\username\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
      

      and for all users it is

      C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Start-up
      

      Then just drop a shortcut to your form (the same one I mentioned above) in one of these folders.

    3. Another option is to register it in the Windows registry. Christophe Geers has a good solution to this here

    For your other problem, read this other StackOverflow question