Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to uninstall a windows service and delete its files without rebooting

My current project involves deploying an upgraded .exe file that runs as a Windows Service. In order to overwrite the existing .exe with the new version, I currently need to:

  1. Stop the service
  2. Uninstall the service
  3. Reboot the system (so Windows releases it's hold on the file)
  4. Deploy the new .exe
  5. Reinstall the service
  6. Start the upgraded service.

I'd like to avoid the reboot, so that this can be a fully scripted/automated upgrade.

Is there any way to avoid rebooting? Maybe a command-line tool that will force Windows to give up it's death grip on the old .exe?

like image 563
Nate Sauber Avatar asked Nov 18 '08 18:11

Nate Sauber


People also ask

How do I force a Windows service to delete?

You can also remove services using a command line. Hold down the Windows Key, then press “R” to bring up the Run dialog. Type “SC DELETE servicename“, then press “Enter“.

Can you delete a Windows service?

Click Start | Run and type regedit in the Open: line. Click OK. Scroll down the left pane, locate the service name, right click it and select Delete.


1 Answers

sc delete "service name" 

will delete a service. I find that the sc utility is much easier to locate than digging around for installutil. Remember to stop the service if you have not already.

like image 131
StingyJack Avatar answered Sep 30 '22 18:09

StingyJack