Re-deployment of services

So I had to write a windows-service, and as usual development-exercise I followed a rather agile development-pattern. So I coded something, installed it and figured that I was missing out on something. OK, no prob. Just do some more coding, uninstall the existing service and install the new version of the service. For that matter I just did an:

%windir%\microsoft.net\framework\v2.0.50727\installutil /u ServiceHost.exe
%windir%\microsoft.net\framework\v2.0.50727\installutil ServiceHost.exe

But after executing these two actions in a nice and handy batch-file I was prompted with an error, that the new service could not be installed! What a rip-off! So I needed to restart Windows in order to re-install my new version of my service.

After some testing I figured, that I need to pause a seconds or so between un-installing and re-installing a service. After modifying my batch to this, everything worked out as expected:

%windir%\microsoft.net\framework\v2.0.50727\installutil /u ServiceHost.exe
pause
%windir%\microsoft.net\framework\v2.0.50727\installutil ServiceHost.exe

Leave a Comment.