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)
{
base.Install(stateSaver);
// Now start the app
Process.Start(Context.Parameters["assemblypath"]);
}
public override void Uninstall(IDictionary savedState)
{
// Kill the Tray Icon
Process[] procs = Process.GetProcessesByName("My SysTray");
foreach (Process DBSTray in procs)
{
DBSTray.Kill();
}
// Now continue with Uninstall
base.Uninstall(savedState);
}
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.
9d321792-ffe2-4faa-9520-536a9022e5fd|0|.0|96d5b379-7e1d-4dac-a6ba-1e50db561b04