Uninstalling windows services

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

This is the first time i am deploying a product.
I have a product with two windows services.In my setup project I have two
checkboxes which gives the user a choice to install either both or just one
of the service.
The install works fine in all cases.
I have a problem with uninstall.
If the user chooses to install only one service ,then there is a problem
uninstalling my product.
Cause the uninstall custom action has active outputs of both the
services,and if one of the service is not installed then the product does'nt
get removed completely.
How can I set a condition for the uninstall custom action??
Any Ideas?
Thanks and Regards.
 
In your custom installer you can persist information about the installation
to be used later when unstalling. The information can be added to the
IDictionary object passed to the Install method:

public override void Install(IDictionary stateSaver)
{
base.Install (stateSaver);
stateSaver.Add("test", "some information");
}

When uninstalling you can retrieve this information:

public override void Uninstall(IDictionary savedState)
{
base.Uninstall(savedState);
if (savedState == null)
{
// Report error
}
else
{
string v = savedState["test"] as string;
// Use retrieved information
}
}

Don't forget to add your installer to the Uninstall custom action.

HTH, Jakob.
 
Back
Top