R – Uninstall Windows Service from Deployment package

deploymentservicevisual-studiowindows

I know that you can install your Windows Service via the VS deployment system which I've done. But how do you deploy updates after that? Each time I deploy a new version, it says that the service already exists and exits.

I tried to add a little DOS CMD file with the following:
net stop [ServiceName]
sc delete [ServiceName]

It would work fine if I could just get to run it, but the custom scripts options in the Deployment system doesn't allow that file type.

How can I either a). Update my package on the clients pc or b). run that uninstall utility from within my installer so I can run the update?

Any help would be greatly appreciated.

Regards,

Storm

Best Solution

If the service is already installed, all you need to do is NET STOP it, replace the exe, then NET START the service.