Fix Windows Server Installation Loop Errors: Service Already Exists/Does Not Exist

windows-server-2012-r2windows-service

When installing an in-house developed service on a Windows Server 2012 R2, the system has somehow come into a state where InstallUtil.exe thinks a service both exists and does not exist. Upon installation command, the process starts and rolls back with the error:

System.ComponentModel.Win32Exception: The specified service already exists

Upon giving InstallUtil.exe an uninstall command for that very service file, the process ultimately completes with the error:

System.ComponentModel.Win32Exception: The specified service does not exist as an installed service

The service did in fact exist prior to my attempt to uninstall and reinstall, though I can find no traces of it now in the Powershell command Get-Service, nor assembly files, nor in the registry. I believe this was triggered by the service name changing in the compiled software without a complete uninstall/reinstall (as in, simply overwriting the executable). My question is, what can I do now to diagnose the issue?

Best Answer

The cause was found and determined to be: another developer had inadvertently added a second service installer with the exact same service name in the project. (He had not tested this change, of course.) The net result of attempting to install two services with the exact same name was not reflected in any of the Windows or installation logs, nor in the command prompt when the service was installed via command line.

To make this diagnosis, I had gone into the source code and altered the service name myself. When rebuilt and installed, two services had been added to the Services list.

Related Topic