How can I stop an .exe on repair, update and delete in wix?
Asked Answered
H

2

2

In my wix I use the following declaration:

<ComponentGroup Id="BinComponents" Directory="BIN">
  <Component Id="BinComponent" Guid="23D229D0-06EE-49f4-80B4-6D7136500721">

    <File Id="MyProjectOutput" Name="MyProject.exe" Source="MyProject\bin\MyProject.exe"/>
    <ServiceControl Id="RemoveService"
       Stop="both"
       Remove="both"
       Name="MyProject.exe"
       Wait="yes" /> <!-- Stop running MyProject instances -->

  </Component>
</ComponentGroup>

My Repro:

At first, I run my installation as usual. After the installation, I start my web application. An .exe appears in the task manager as usual:

enter image description here

I want to end this .exe on a repair, update or uninstall. So I start my .msi again and choose repair:

enter image description here

Now my problem: After pressing 'Repair', I expect the following dialog because of the declared ServiceControl:

enter image description here

But it doesn´t. Instead, the following dialog appears:

enter image description here

When I log the setup, the log shows the following lines:

MSI (s) (A8:DC) [10:16:28:227]: Executing op: ActionStart(Name=StopServices,Description=Stopping services,Template=Service: [1])
Action 10:16:28: StopServices. Stopping services
MSI (s) (A8:DC) [10:16:28:228]: Executing op: ProgressTotal(Total=1,Type=1,ByteEquivalent=1300000)
MSI (s) (A8:DC) [10:16:28:228]: Executing op: ServiceControl(,Name=MyProject.exe,Action=2,Wait=1,)
MSI (s) (A8:DC) [10:16:28:228]: Executing op: ActionStart(Name=DeleteServices,Description=Deleting services,Template=Service: [1])
Action 10:16:28: DeleteServices. Deleting services
MSI (s) (A8:DC) [10:16:28:228]: Executing op: ProgressTotal(Total=1,Type=1,ByteEquivalent=1300000)
MSI (s) (A8:DC) [10:16:28:229]: Executing op: ServiceControl(,Name=MyProject.exe,Action=8,Wait=1,)
MSI (s) (A8:DC) [10:16:28:229]: Executing op: ActionStart(Name=InstallFiles,Description=Copying new files,Template=File: 
[1],  Directory: [9],  Size: [6])

[...]

MSI (s) (7C:28) [09:06:21:950]: RESTART MANAGER: Did detect that a critical application holds file[s] in use, so a reboot will be necessary.
MSI (s) (7C:28) [09:06:21:950]: Note: 1: 1610 
MSI (s) (7C:28) [09:06:21:950]: Note: 1: 2205 2:  3: Error 
MSI (s) (7C:28) [09:06:21:950]: Note: 1: 2228 2:  3: Error 4: SELECT `Message` FROM `Error` WHERE `Error` = 1610 

Next to a Repair I also have tried an Update with the same results. Perhaps any declaration missing? Note: When I close the MyApp.exe in the task manager, the message does not appear, so the MyApp.exe is definitely responsible for the problem.

Heeling answered 2/7, 2015 at 8:56 Comment(0)
A
2

The warning dialog that you are seeing is from "InstallValidate" standard action. I have run into a similar issue in the past . I fixed it by making use of a single service control element instead of multiple service control elements, for the same service id. In my case, i had multiple service control elements for the same service id.

This is as per the link at http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Upgrade-uninstall-restart-issue-td7586315.html

This did the trick for me. Numerous users have reported the same behavior, though its not officially documented. Having a single service control element makes Restart Manager take note of the entry in the Service Control table and will prevent Restart Manager from listing the service in the RMFilesInUse dialog box or will prevent Restart Manager from throwing up warning messages informing the user that a restart might be required. Here is one more link Can't start windows service with WiX

My experiments have shown me that there is definitley a link between the number of service control elements and Restart Manager http://microsoft.public.windows.msi.narkive.com/OOuQQAsw/controlling-restart-manager-behaviour

The other option was to totally disable Restart Manager using the property RESTARTMANAGERCONTROL, In case, you disable the RestartManager, you might be prompted for reboots(you might want to test it once) and the legacy "Files in Use" mechanism kicks off. Disabling Restart Manager is a conscious decision by the concerned msi developer and at times becomes necessary.

I am not sure about how your Service Control table looks like. Just wanted to share my experience with you.

Hopefully it helps.

Regards, Kiran Hegde

Abbatial answered 6/7, 2015 at 6:31 Comment(2)
Hedge: Thank you for your answer. I already use only a single ServiceControl element as you can see in my post.Heeling
Well, if thats the case then i would request you to post a verbose windows installer log. Thats the only way to proceed further.Abbatial
W
1

You should post the entire log somewhere. The root cause is that a repair shouldn't routinely require files to be replaced. So if you literally installed your product, ran the exe, and then a repair needs to replace files, then the issue is not that files-in-use dialog - it's that the installed product is broken, so required files or registry entries have been removed. The application event log should have MsiInstaller entries that describe a missing component. So look at that root cause first.

After fixing that it should be very rare for a repair to need to replace files, so it may not be worth worrying about. But you could look at integrating your app with Restart Manager or using the WiX util CloseApplication.

Worthwhile answered 2/7, 2015 at 18:14 Comment(5)
I have checked the log. There is no entry about a missing component. The installed prouduct seems not to be broken.Heeling
With an Update, I get the same results.Heeling
Regarding your answer "After fixing that it should be very rare for a repair to need to replace files, so it may not be worth worrying about": As mentioned → there is no missing componend and I should worry about. The administrators who install the software on their Windows Server cannot restart their machine. They see the message "... reboot required..." and cancel the setup and do not buy the product.Heeling
There must be a reason that repair needs to replace files, by definition it means the installed product is broken in the sense that the files or registry entries on the system no longer match the definition in the MSI file. The app can keep on working of course. There is not enough in your log to diagnose the issue. There is exactly what you'd expect to see for a file that needs replacing, but the reason and the later replacement action are not shown. There's still WiX usil CloseApplication, but it's still true that repair doesn't replace files unless something is incorrect.Worthwhile
can I send you my entire log per E-Mail for a lookup? What is your address?Heeling

© 2022 - 2024 — McMap. All rights reserved.