views:

514

answers:

3

Hi There,

I have created a windows service, it works great, but as soon as I try to install the service, it removed the directory, however, the service did not get removed, and when I try to install the service again, it give me an error 1001: Service already exists. How can I fix that?

And also, is there any code for me to remove the service when I uninstall the project?

Thanks

A: 

You might need to remove it from the registry at [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services]

Mladen Mihajlovic
still doesn't work, the service stays on Services, but no description, and when I try to reinstall again, it gave me the same error.
PlayKid
long tail, but if you remove a service in this manner you need to restart your machine to see the changes. Also note that on 64 bit machines there is both a 32 and 64 bit version of the registry
keith
A: 

Have a look at this post. It references another one, so, between them, they may have your solution.

dommer
+1  A: 

You can use installutil.exe to install or uninstall a service from the command line.

To install: installutil yourproject.exe

To uninstall: installutil /u yourproject.exe

You can also use sc delete from the command line. Type sc by itself to get the list of parameters.

Lastly you can use the ServiceInstaller.Uninstall() method if you're using the predefined installation component. You'll have to call it from the Uninstall handler of your installer.

Arnshea