Skip to content

fix MSI upgrade hanging due to service not stopped before file removal#415

Draft
inqrphl wants to merge 3 commits into
mainfrom
fix-msi-installer-hang-when-service-is-runnning
Draft

fix MSI upgrade hanging due to service not stopped before file removal#415
inqrphl wants to merge 3 commits into
mainfrom
fix-msi-installer-hang-when-service-is-runnning

Conversation

@inqrphl

@inqrphl inqrphl commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

The commit is made entirely using AI, I will only mark it done once I test it.

During upgrades, RemoveExistingProducts (scheduled by MajorUpgrade) ran before CustomPreUpdateAction, which is what stops the snclient Windows service. This meant the old snclient.exe was still held by the running service when MSI tried to delete it. Combined with Restart Manager being disabled (MSIRESTARTMANAGERCONTROL=Disable), MSI could not shut down the process holding the file, causing the installer to show a "Files in Use" dialog or silently fail.

Fixed by:

  • Setting MajorUpgrade Schedule="afterInstallInitialize" so old files are removed after InstallInitialize instead of before it
  • Adding Before="RemoveExistingProducts" to CustomPreUpdateAction so snclient.exe install pre stops the service before file removal

The corrected sequence during upgrades is now:
InstallInitialize -> stop service -> remove old files -> install new files -> start service -> InstallFinalize

…file removal

During upgrades, RemoveExistingProducts (scheduled by MajorUpgrade) ran
before CustomPreUpdateAction, which is what stops the snclient Windows
service. This meant the old snclient.exe was still held by the running
service when MSI tried to delete it. Combined with Restart Manager
being disabled (MSIRESTARTMANAGERCONTROL=Disable), MSI could not shut
down the process holding the file, causing the installer to show a
"Files in Use" dialog or silently fail.

Fixed by:
- Setting MajorUpgrade Schedule="afterInstallInitialize" so old files
  are removed after InstallInitialize instead of before it
- Adding Before="RemoveExistingProducts" to CustomPreUpdateAction so
  snclient.exe install pre stops the service before file removal

The corrected sequence during upgrades is now:
  InstallInitialize -> stop service -> remove old files -> install
  new files -> start service -> InstallFinalize
@inqrphl inqrphl marked this pull request as draft July 15, 2026 16:34
inqrphl added 2 commits July 15, 2026 18:40
…ateAction, it is sufficient that it has Before="RemoveExistingProducts"
…file removal

During upgrades, RemoveExistingProducts ran before CustomPreUpdateAction,
so the old snclient.exe was still held by the running service when MSI
tried to delete it. MSIRESTARTMANAGERCONTROL is disabled, so Restart
Manager could not shut down the process, causing the installer to hang
on a "Files in Use" dialog.

Fixed by scheduling MajorUpgrade to afterInstallExecute, which installs
the new product on top of the old and removes stale components later.
CustomPreUpdateAction runs after InstallInitialize, well before
InstallFiles, so the service is stopped before the binary is replaced.

Resulting upgrade sequence:
  InstallInitialize -> stop service -> InstallFiles (overwrites exe) ->
  InstallExecute -> RemoveExistingProducts -> start service -> InstallFinalize
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant