.NET ServiceInstaller get too much time for uninstall services

Posted by rodnower on Stack Overflow See other posts from Stack Overflow or by rodnower
Published on 2010-04-17T08:56:56Z Indexed on 2010/04/17 9:03 UTC
Read the original article Hit count: 196

Hello, we have some Setup Project wrote in Visual Studio 2008 in C# that installs and uninstalls services with ServiceInstaller class.
When I install the services this don't get too much time, but when I uninstall with following code the process for each service get few seconds (and we have many services):

ServiceInstaller si = new ServiceInstaler();
string path = string.Format("/assemblypath={0}", strServiceExecutablePath);
string[] cmdline = { path };

InstallContext context = new InstallContext(string.Empty, cmdline);
si.Context = context;
si.ServiceName = strServiceName;
si.Uninstall(null);

Some one know why?

Here I want to ask some related question.
What difference between working of:

InstallUtill /u exePath

when it uninstall service and:

sc delete serviceName

And why when I delete some record from registry from CurrentControlSet\services I still see the service in services.msc but with:

<Failed to read description. Error code:2

In description?
From where I need to delete service manually for delete it complitely?
Thank you for ahead.

© Stack Overflow or respective owner

Related posts about installer

Related posts about c#