Search code examples
c#windows-services

Removing/installing a Windows Service


I've created a Windows Service project in C#, just some very simple code. It worked when i installed the service, but now I have to add some code and so on,but that has caused some issues:

1) When trying to uninstall using "installutil /u" it says its removed however its still on the service list in computeradministration.

1a) I tried to delete it with cmd using "sc delete ServiceName" which removes it from the list

2) BUT when i install the new build it succeeds, however it still uses the old build for some reason, and im kindda at a loss.


Solution

  • You only have to install once. The service will be registered with the .exe you registered using sc or installutil.

    To replace the binary, just stop the service, replace the binary with the "new" one and restart: the new service will be running.

    Also, you have to restart services.msc to see that some services are removed (there seems to be some "pending removal" flag).