Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upgrade a Windows Service without Uninstalling

Currently I have to uninstall the old version of my service before I install the new version. I am pretty sure this has something to do with it not being smart enough to update or remove the old service entries before adding the new ones.

Is there a way to have the installer skip registering the service if it already exists? (I can assume the installation folder and service name do not change between versions.)

Also, is there a way to automatically stop the service when uninstalling?


Edit:

I am using MSI packages and the Visual Studio setup project.

like image 852
Jonathan Allen Avatar asked Nov 29 '08 19:11

Jonathan Allen


People also ask

How do you update Windows services?

To check for updates manually, select the Start button, then select Settings > Update & Security > Windows Update >, and then select Check for updates.

How do I remove a service from Windows Service?

Navigate to the key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services. Backup the services key. Identify the service that you want to delete. Left-click on that service and press delete on the keyboard.


1 Answers

I've done this with WiX, which generates .MSI files using the ServiceInstall & SeviceControl commands:

<Component Id='c_WSService' Guid='*'>     <File Id='f_WSService' Name='WSService.exe' Vital='yes' Source='..\wssvr\release\wsservice.exe' KeyPath="yes" />     <ServiceInstall Id='WSService.exe' Name='WSService' DisplayName='[product name]' Type='ownProcess'                     Interactive='no' Start='auto' Vital='yes' ErrorControl='normal'                     Description='Provides local and remote access to [product name] search facilities.' />     <ServiceControl Id='WSService.exe' Name='WSService' Start='install' Stop='both' Remove='uninstall' Wait='yes' /> </Component> 

This stops the service, installs the new version and re-starts the service.

like image 167
Ferruccio Avatar answered Sep 22 '22 18:09

Ferruccio