Massoud Mazar

Sharing The Knowledge


Using an Installer Class to Start/Remove Tray Icon

Suppose you want to start your SysTray application at installation time and remove it when your application is uninstalled. Here is one way to do this:

Add an Installer Class to your project, and overwrite the Install and Uninstall methods. For Example, assuming your SysTray program is named "My SysTray":

public override void Install(IDictionary stateSaver)
    // Now start the app

public override void Uninstall(IDictionary savedState)
    // Kill the Tray Icon
    Process[] procs = Process.GetProcessesByName("My SysTray");
    foreach (Process DBSTray in procs)
    // Now continue with Uninstall

To make this work in your Deployment project, Go to "Custom Actions" of the Deployment project and add "Primary output from My SysTray" to all the Custom Actions.

Add comment