From dbad729da3c0eb5e76aa9ffccf298c8feea795be Mon Sep 17 00:00:00 2001 From: jim800121chen Date: Sun, 12 Apr 2026 02:35:13 +0800 Subject: [PATCH] =?UTF-8?q?fix(local-tool):=20Inno=20Setup=20=E5=81=B5?= =?UTF-8?q?=E6=B8=AC=E5=8A=A0=E5=85=A5=20user-scope=20=E5=AE=89=E8=A3=9D?= =?UTF-8?q?=E8=B7=AF=E5=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit winget 7.x 的 Inno Setup 可能裝到 %LOCALAPPDATA%\Programs\Inno Setup 6\ 而非傳統的 Program Files (x86)。新增 user-scope 固定路徑 + HKCU 登錄檔 + %LOCALAPPDATA%\Programs 遞迴掃描三種偵測方式。 Co-Authored-By: Claude Opus 4.6 (1M context) --- local-tool/Makefile | 2 ++ local-tool/scripts/bootstrap-windows.ps1 | 37 +++++++++++++++++------- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/local-tool/Makefile b/local-tool/Makefile index 546e13d..cf7d794 100644 --- a/local-tool/Makefile +++ b/local-tool/Makefile @@ -466,6 +466,8 @@ exe: wails-windows ## ⚠️ 必須在 Windows 上跑:Inno Setup → dist/visi else \ for p in "/c/Program Files (x86)/Inno Setup 6/ISCC.exe" \ "/c/Program Files/Inno Setup 6/ISCC.exe" \ + "$$LOCALAPPDATA/Programs/Inno Setup 6/ISCC.exe" \ + "$$USERPROFILE/AppData/Local/Programs/Inno Setup 6/ISCC.exe" \ "/c/Program Files (x86)/Inno Setup 5/ISCC.exe"; do \ if [ -f "$$p" ]; then ISCC_BIN="$$p"; break; fi; \ done; \ diff --git a/local-tool/scripts/bootstrap-windows.ps1 b/local-tool/scripts/bootstrap-windows.ps1 index cf41c2b..906735d 100644 --- a/local-tool/scripts/bootstrap-windows.ps1 +++ b/local-tool/scripts/bootstrap-windows.ps1 @@ -107,31 +107,48 @@ $msysPython = Convert-ToMsysPath $realPython # 找 Inno Setup Compiler (ISCC.exe) # 重要:檔名是 ISCC.exe(大寫),winget 裝在 Program Files (x86) 不在 PATH 裡 function Find-Iscc { + # 1. 固定路徑(system + user scope) $candidates = @( "${env:ProgramFiles(x86)}\Inno Setup 6\ISCC.exe", "$env:ProgramFiles\Inno Setup 6\ISCC.exe", + "$env:LOCALAPPDATA\Programs\Inno Setup 6\ISCC.exe", + "$env:USERPROFILE\AppData\Local\Programs\Inno Setup 6\ISCC.exe", "${env:ProgramFiles(x86)}\Inno Setup 5\ISCC.exe" ) foreach ($p in $candidates) { if ($p -and (Test-Path $p)) { return $p } } - # 從登錄檔找 Inno Setup 的安裝路徑 + # 2. 登錄檔 Uninstall key(HKLM + HKCU 都看) $regPaths = @( 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Inno Setup 6_is1', - 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Inno Setup 6_is1' + 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Inno Setup 6_is1', + 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Inno Setup 6_is1' ) foreach ($rp in $regPaths) { $item = Get-ItemProperty $rp -ErrorAction SilentlyContinue - if ($item -and $item.InstallLocation) { - $p = Join-Path $item.InstallLocation 'ISCC.exe' - if (Test-Path $p) { return $p } + if ($item) { + if ($item.InstallLocation) { + $p = Join-Path $item.InstallLocation 'ISCC.exe' + if (Test-Path $p) { return $p } + } + if ($item.'Inno Setup: App Path') { + $p = Join-Path $item.'Inno Setup: App Path' 'ISCC.exe' + if (Test-Path $p) { return $p } + } } } - # 最後備案:掃 Program Files 底下 - $found = Get-ChildItem -Path "${env:ProgramFiles(x86)}","$env:ProgramFiles" ` - -Filter 'ISCC.exe' -Recurse -ErrorAction SilentlyContinue -Force | - Select-Object -First 1 - if ($found) { return $found.FullName } + # 3. 遞迴掃 Program Files + user AppData + $scanRoots = @( + "${env:ProgramFiles(x86)}", + "$env:ProgramFiles", + "$env:LOCALAPPDATA\Programs" + ) | Where-Object { $_ -and (Test-Path $_) } + foreach ($root in $scanRoots) { + $found = Get-ChildItem -Path $root -Filter 'ISCC.exe' -Recurse ` + -ErrorAction SilentlyContinue -Force | + Select-Object -First 1 + if ($found) { return $found.FullName } + } return $null }