I am late, but would like to add an alternative, which may look strange, but I didn't see another way:
As I install my Windows Services in a CI process each night, I needed something that works all the time and is completely automated. For some reason, the services were always marked for deletion for a long time (5 minutes or more) after uninstalling them. Therefore, I extended the reinstallation batch script to make sure that the service is really deleted (simplified version):
REM Stop the service first
net stop My-Socket-Server
REM Same as installutil.exe, just implemented in the service
My.Socket.Server.exe /u
:loop1
REM Easy way to wait for 5 seconds
ping 192.0.2.2 -n 1 -w 5000 > nul
sc delete My-Socket-Server
echo %date% %time%: Trying to delete service.
if errorlevel 1072 goto :loop1
REM Just for output purposes, typically I get that the service does not exist
sc query My-Socket-Server
REM Installing the new service, same as installutil.exe but in code
My.Socket.Server.exe /i
REM Start the new service
net start My-Socket-Server
What I can see, is that the service is marked for deletion for about 5 minutes (!) until it finally goes through. Finally, I don't need any more manual interventions. I will extend the script in the future so that something happens after a certain time (e.g. notification after 30 minutes).