I created an application at work called LMC Listener. Its job is to listen to activities in a specified folder based on the current year. If there's activity, then delete the files from the copyto location and copy the files from the copyfrom location.
This tutorial is simple, I will show you how to run your app in the background at startup and in the system tray. You should have already built or compiled your app into an exe file.
1. The first step is add a Notifyicon control and a Context Menu control from the toolbox to your windows form.
2. Go to the properties of the Notifyicon control and set the properties of that control.
3. Go to the properties of the Context Menu control and Right click the control and choose Edit. Since this menu will appear when your right-click the icon in the system tray, you will want to add an Exit menu item.
4. Now that you have the Exit menu (button) double click to add the event to the forms code. Then add the following code to close the application.
Application.Exit();
5. Now let's control the Form. Set the following to the Form property window.
FormBorderSize: Fixed Tool Window
WindowState: Minimized
Opacity: 0%
ShowInTaskbar: False
Now that the application is configured for the system tray, rebuilt your app and run it. The application should show in the system tray. Note, the main form cannot be used as an application form. Create another form in your application and call that form, adding an additional item in the Context Menu to do other things.
Configuring the application to run at Windows startup
Now, let's configure the application to start when the user logs in.
To make an application run at every startup, create a shortcut to the application and place the shortcut in the Startup folder of the user who will log on or under the ALLUSERS Profile.
Click Start, Run and type:
%userprofile%\Start Menu\Programs\Startup
This opens the Startup folder of your user profile. Now, right-click the folder and choose New, Shortcut and type the path for the filename which you want to execute at startup. You can simply drag the application shortcut also. This affects only your user profile startup.
To have the application run at startup for every user who logon to the computer, place the shortcut in this path instead:
%allusersprofile%\Start Menu\Programs\Startup