From 332544fa07837c6af135ef2b4a7ef812a312f365 Mon Sep 17 00:00:00 2001 From: Martin Ball Date: Mon, 30 Nov 2026 09:59:20 +0000 Subject: [PATCH] fix(installer): drop the PowerShell association-notify action Defender blocks #1080 ran a hidden PowerShell after install and uninstall that P/Invoked shell32 SHChangeNotify(SHCNE_ASSOCCHANGED). Microsoft Defender flags that pattern as a malicious command line and shows the user a security alert (reported on v0.23.0). Remove the custom action; test-msi.ps1 now fails if any custom action runs PowerShell. Trade-off: Explorer's cached "Open with" list may miss PdfCraft until sign-out after a fresh install, as before #1080. Co-Authored-By: Claude Opus 5.5 --- packaging/windows/pdfcraft.wxs | 12 ------------ packaging/windows/test-msi.ps1 | 18 +++++++++--------- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/packaging/windows/pdfcraft.wxs b/packaging/windows/pdfcraft.wxs index cfa379df00..94c1d1be85 100644 --- a/packaging/windows/pdfcraft.wxs +++ b/packaging/windows/pdfcraft.wxs @@ -74,7 +74,6 @@ - @@ -84,17 +83,6 @@ - - - - - diff --git a/packaging/windows/test-msi.ps1 b/packaging/windows/test-msi.ps1 index c73c7d5faf..a800baada6 100644 --- a/packaging/windows/test-msi.ps1 +++ b/packaging/windows/test-msi.ps1 @@ -249,15 +249,15 @@ if ($pdfCheckbox[2] -notmatch '&Edit' -or $pdfCheckbox[2] -notmatch 'Combine fil $pdfChecked = Read-Row 'SELECT `Value` FROM `CheckBox` WHERE `Property` = ''INSTALLPDFCONTEXTMENU''' 1 Assert-Equal $pdfChecked[0] '1' 'Welcome PDF context-menu value' Assert-NoRow 'SELECT `Registry` FROM `Registry` WHERE `Key` = ''Software\Classes\.pdf'' AND `Name` IS NULL' '.pdf default app' -# #1080: Explorer is told the associations changed (SHCNE_ASSOCCHANGED) after install/uninstall, -# without ever failing setup. 34 = exe in a directory; 64 = ignore its exit code. -$notify = Read-Row 'SELECT `Type`, `Source`, `Target` FROM `CustomAction` WHERE `Action` = ''NotifyAssociationsChanged''' 3 -Assert-Equal $notify[0] '98' 'Association notify action type' -Assert-Equal $notify[1] 'SystemFolder' 'Association notify directory' -if ($notify[2] -notmatch 'SHChangeNotify\(0x8000000,0,0,0\)' -or $notify[2].Length -gt 255) { throw "Association notify command: '$($notify[2])'" } -$after = Read-Row 'SELECT `Sequence` FROM `InstallExecuteSequence` WHERE `Action` = ''NotifyAssociationsChanged''' 1 -$finalize = Read-Row 'SELECT `Sequence` FROM `InstallExecuteSequence` WHERE `Action` = ''InstallFinalize''' 1 -if ([int] $after[0] -le [int] $finalize[0]) { throw 'Association notify must run after InstallFinalize' } +# No custom action runs PowerShell: Defender blocks hidden PowerShell that P/Invokes shell32 as +# malicious (it did for #1080's SHChangeNotify action), and the user sees a security alert. +$actionView = $Database.OpenView('SELECT `Action`, `Target` FROM `CustomAction`') +try { + [void] $actionView.Execute() + while ($record = $actionView.Fetch()) { + if ($record.StringData(2) -like '*powershell*') { throw "custom action runs PowerShell: $($record.StringData(1))" } + } +} finally { [void] $actionView.Close() } # "Combine files in PdfCraft" (#585): in the PDF menu's component, so the one switch covers both # verbs. Each selected file starts `pdfcraft --combine ""` (Document), and the running