2

I come upon the warning message during uninstalls a product or major updates in the uninstall phase (when a product service is running):

"The setup must update files or service that cannot be updated while the system is running. If you choose continue, a reboot will be required to complete the setup."

Story starts here

I have developed the windows service and created the installer [msi] using Wix, then distributed to users. it is working as expected.

Now, it's time to deliver a new build with service enhancements. Hence, I have created a new msi. I was hoping that the execution of new msi shall upgrade the existing application.

But I get below error

The setup must update files or services that cannot be updated while the system is running

To support MSI upgrade, I have made below changes

Existing code for Product section

  <?define UpgradeCode = "{3D197FE4-86DF-31FD-A0CD-21B5D3B97ABC}" ?>
  <Product Id="$(var.ProductCode)" 
       Name="!(loc.ProductName_$(var.Platform)) $(var.ProductVersion)"
       Language="!(loc.Language)" 
       Version="$(var.BuildVersion)"
       Manufacturer="!(loc.Company)" 
       UpgradeCode="$(var.UpgradeCode)">

Changed code, Here Product ID changed to *

  <?define UpgradeCode = "{3D197FE4-86DF-31FD-A0CD-21B5D3B97ABC}" ?>
  <Product Id="*" 
       Name="!(loc.ProductName_$(var.Platform)) $(var.ProductVersion)"
       Language="!(loc.Language)" 
       Version="$(var.ProductVersion)"
       Manufacturer="!(loc.Company)" 
       UpgradeCode="$(var.UpgradeCode)">

Observe that upgrade code is not changed from old version to new version.

Existing code for upgrade

    <MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeErrorMessage)" />

Updated code for upgrade

      <MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeErrorMessage)"
                AllowDowngrades="no"
                AllowSameVersionUpgrades="yes" 
                RemoveFeatures="ALL" 
                Schedule="afterInstallInitialize"/>

Is it anything to do with service?

     <ServiceControl Id="myservice"
                    Name="GatewayService"
                    Start="install"
                    Stop="both"
                    Remove="uninstall" Wait="yes" />

Install Sequence

enter image description here

How to get rid of this prompt? Also why it's coming if service is stopped.

enter image description here

Some part of logs

     MSI (s) (78:5C) [19:54:21:691]: WIN64DUALFOLDERS: Substitution in 'C:\Program Files (x86)\Service\Service.dll' folder had been blocked by the 1 mask argument (the folder pair's iSwapAttrib member = 0).
     The setup must update files or services that cannot be updated while 
     the system is running. If you choose to continue, a reboot will be 
     required to complete the setup.
     MSI (s) (78:5C) [19:54:53:705]: Note: 1: 2727 2:  
     MSI (s) (78:5C) [19:54:53:706]: Doing action: RemoveExistingProducts
     MSI (s) (78:5C) [19:54:53:706]: Note: 1: 2205 2:  3: ActionText 
     Action ended 19:54:53: InstallValidate. Return value 1.
     MSI (s) (78:5C) [19:54:53:706]: Skipping RemoveExistingProducts action: 
     current configuration is maintenance mode or an uninstall
     Action start 19:54:53: RemoveExistingProducts.
     MSI (s) (78:5C) [19:54:53:706]: Doing action: InstallInitialize
     MSI (s) (78:5C) [19:54:53:706]: Note: 1: 2205 2:  3: ActionText 
     Action ended 19:54:53: RemoveExistingProducts. Return value 0.
     MSI (s) (78:5C) [19:54:53:708]: Machine policy value 'AlwaysInstallElevated' is 0
     MSI (s) (78:5C) [19:54:53:708]: User policy value 'AlwaysInstallElevated' is 0

I have below code to restart service on failure. do u think it causes issue?

       <util:ServiceConfig xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"
                FirstFailureActionType="restart"
                SecondFailureActionType="restart"
                ThirdFailureActionType="restart" />

Issue root cause

I see that old version is not getting deleted during upgrade. Hence created a new question here Wix installer upgrade with same "upgrade code" ID shows privilege error prompt

kudlatiger
  • 3,028
  • 8
  • 48
  • 98
  • Do you have [a full, verbose log](https://stackoverflow.com/questions/54453922/enable-installation-logs-for-msi-installer-without-any-command-line-arguments/54458890#54458890)? What files are in use when you install? Services frequently cause this error if you don't stop them before trying to overwrite, but it looks like you stop them properly. **How long does the service take to stop when you stop it manually from the service control applet?** Do you have other binaries or any other files you install that might be locked? – Stein Åsmul Aug 28 '19 at 10:24
  • Service takes a 4-5 seconds to stop when I try manually. I have uploaded screenshot of my install sequence in question. No other files locked. only one EXE related to service locked. – kudlatiger Aug 28 '19 at 14:02
  • Are you setting `REINSTALLMODE="amus"` on install? Are you including any merge modules or runtimes? Maybe quickly check this: https://www.advancedinstaller.com/forums/viewtopic.php?t=35059 - do you downgrade the file? – Stein Åsmul Aug 28 '19 at 16:02
  • No, I did not set REINSTALLMODE="amus". I am not including any merge modules. – kudlatiger Aug 29 '19 at 01:37
  • I see in control panel that there is already old version of "service" not uninstalled during upgrade. I think this is causing service not to delete. How can we make sure we delete the old when we upgrade? I have uninstalled old version then newer version uninstalled without any prompts . – kudlatiger Aug 29 '19 at 03:48
  • Are you testing the MSI on your dev machine or on a clean machine? Maybe you got the "older" instance of the service somehow published/registered directly by Visual Studio, and not by the older version of your MSI. – Bogdan Mitrache Aug 29 '19 at 07:01
  • @BogdanMitrache I am testing on clean machine but i found that old verison is not getting deleted during upgrade, hence above issue. so i created new question here https://stackoverflow.com/questions/57703489/wix-installer-upgrade-with-same-upgrade-code-id-shows-privilege-error-prompt – kudlatiger Aug 29 '19 at 07:20
  • issue resolved!!! Thanks, everyone. – kudlatiger Aug 30 '19 at 14:48

2 Answers2

1

Issue resolved. Culprit was below code

    <util:ServiceConfig xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"
            FirstFailureActionType="restart"
            SecondFailureActionType="restart"
            ThirdFailureActionType="restart" />

I have added delay as follow, and everything working like charm now.

     RestartServiceDelayInSeconds="60"

Thanks to someone who thought the need for RestartServiceDelayInSeconds. Great thinking during ServiceConfig utility development

kudlatiger
  • 3,028
  • 8
  • 48
  • 98
  • 1
    Does this indicate that your service does not do proper shutdown? One would think that would entail shutting down so the service manager does not think it should restart the service? I am not sure. – Stein Åsmul Aug 30 '19 at 19:16
  • I mean: maybe the service reports an error on shutdown and that is why the Service Manager tries to restart it? – Stein Åsmul Aug 30 '19 at 19:31
  • since wix is trying to shutdown during upgrade, the service manager assumes that it's a failure and hence it tries to restart. How do I communicate to service manager that it's a intended shutdown and not a crash. – kudlatiger Aug 31 '19 at 02:33
  • 1
    Yes, I was wondering whether an initiated shutdown would set flags and return valid exit codes to inform the service manager that the shutdown was planned. I am not sure how this works, might take a look later. I had a service like that once - it had intermittent crashes during UAT and we used that restart feature - I still managed to make an MSI deploy it reliably as I recall it. – Stein Åsmul Aug 31 '19 at 10:41
0

So I was installing MongoDB and this message kept popping up. I tried clicking on OK thinking that it would reboot the system but nothing happened. Then I turned off my internet and retried. It worked. This was weird but that's how my problem got resolved.