Skip to content

Fix msiexec hang on Windows — add /qn /norestart to install.ps1#673

Draft
musa-asad wants to merge 1 commit intomainfrom
fix/msiexec-hang-qn-norestart
Draft

Fix msiexec hang on Windows — add /qn /norestart to install.ps1#673
musa-asad wants to merge 1 commit intomainfrom
fix/msiexec-hang-qn-norestart

Conversation

@musa-asad
Copy link
Copy Markdown
Contributor

@musa-asad musa-asad commented Apr 23, 2026

Summary

Fixes indefinite msiexec hang during CloudWatch Agent installation on Windows when another MSI is already in progress (error 1618).

Without /qn, msiexec shows a UI dialog on error. In Session 0 (non-interactive), this dialog is invisible and blocks indefinitely until the calling process times out.

Changes

packaging/windows/install.ps1 line 17:

  • Added /qn (quiet, no UI) — ensures msiexec runs in silent mode so errors return exit codes instead of showing dialogs
  • Added /norestart — prevents unexpected reboots on hosts managed via automation
  • Added -PassThru and exit code check — throws on non-zero exit so failures are reported instead of silently proceeding to cond-restart
  • Exit code 3010 (success, reboot required) is treated as success since /norestart suppresses the reboot

uninstall.ps1 is NOT affected (uses WMI, not msiexec).

Before (hangs on error, no exit code check):

Start-Process msiexec.exe -Wait -ArgumentList '/i amazon-cloudwatch-agent.msi'

After (returns immediately, fails explicitly):

$proc = Start-Process msiexec.exe -Wait -PassThru -ArgumentList '/i amazon-cloudwatch-agent.msi /qn /norestart'
if ($proc.ExitCode -ne 0 -and $proc.ExitCode -ne 3010) {
    throw "msiexec failed with exit code $($proc.ExitCode)"
}

Testing

Reproduced on Windows Server 2025. Process evidence confirmed: msiexec PID stuck in Session 0 with invisible Windows Installer dialog, ThreadWaitReason=UserRequest. MSI mutex NOT held — confirms dialog-wait, not mutex-wait. With /qn, msiexec returns error 1618 immediately instead of hanging. Exit code check ensures real errors propagate while 3010 (reboot-needed) is accepted.

@musa-asad musa-asad requested a review from a team as a code owner April 23, 2026 15:38
@musa-asad musa-asad force-pushed the fix/msiexec-hang-qn-norestart branch from e06393f to c35f2dd Compare April 23, 2026 15:44
Without /qn, msiexec shows a UI dialog on error (e.g. MSI mutex
conflict 1618). In Session 0 (SSM/non-interactive), this dialog is
invisible and blocks indefinitely. Adding /qn ensures silent mode
so errors return immediately. /norestart prevents unexpected reboots.
@musa-asad musa-asad force-pushed the fix/msiexec-hang-qn-norestart branch from c35f2dd to bdf87f8 Compare April 23, 2026 15:50
@musa-asad musa-asad marked this pull request as draft April 29, 2026 23:50
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