peterk
Posts: 17
Joined: Wed Aug 03, 2022 3:23 pm

Start windows service only during upgrade

In our project we have a chicken/egg problem where during the first installation of our product we want to create the service but we don't want to start it. This is due to customer configuration that is needed on a settings file that after first installation, does not get changed on subsequent upgrades. So during any upgrade we want to stop, upgrade the software (not overwrite settings file), start the service but only on upgrade, never first installation. I don't see away to do this.

The only way I can see would be to on install NOT start the service and then have custom actions on upgrade that do:
1) sc.exe stop "myCustomService"
2) run upgrade
3) sc.exe start "myCustomService"
Liviu
Posts: 1329
Joined: Tue Jul 13, 2021 11:29 am
Contact: Website

Re: Start windows service only during upgrade

Hello,

You can right click on your Control Operations --> Go to Component option and add the condition OLDPRODUCTS. In this way, the control operation will only be executed during an upgrade.

An upgrade process can be detected by using two properties:
  • OLDPRODUCTS - this property is set in the upgrading MSI if the package found an older version installed on the target machine
  • UPGRADINGPRODUCTCODE - this property is set in the MSI which is being upgraded if the package is uninstalled by a newer version
Go to Component.png
Go to Component.png (41.46 KiB) Viewed 9880 times
OLDPRODUCTS.png
OLDPRODUCTS.png (26.25 KiB) Viewed 9880 times

You can add multiple operations and condition when to execute them.

If you cannot configure the Control Operations to your needs, you should look at the custom actions approach as you mentioned.

Hope this helps!

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”