Skip to content

Commit ea20356

Browse files
committed
fix(windows): taskbar icon fallback and silent installer PowerShell
Load window icon from the packaged .exe when .ico paths fail (ASAR/unpack layout), and try resources/assets/icon.ico. NSIS ExecWait PowerShell helpers now use -WindowStyle Hidden and -NonInteractive so upgrade/install does not flash console windows. Made-with: Cursor
1 parent 60b9a68 commit ea20356

2 files changed

Lines changed: 17 additions & 8 deletions

File tree

app/windows/build.cjs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,7 @@ let suppressQuitForUpdateInstall = false;
568568
function resolveAppIconIcoPath() {
569569
const candidates = [
570570
process.resourcesPath && path.join(process.resourcesPath, "app.asar.unpacked", "assets", "icon.ico"),
571+
process.resourcesPath && path.join(process.resourcesPath, "assets", "icon.ico"),
571572
app.getAppPath && path.join(app.getAppPath(), "assets", "icon.ico"),
572573
path.join(__dirname, "..", "assets", "icon.ico"),
573574
].filter(Boolean);
@@ -581,13 +582,20 @@ function resolveAppIconIcoPath() {
581582

582583
function nativeImageFromAppIcon() {
583584
const p = resolveAppIconIcoPath();
584-
if (!p) return undefined;
585-
try {
586-
const img = nativeImage.createFromPath(p);
587-
return img.isEmpty() ? undefined : img;
588-
} catch (_) {
589-
return undefined;
585+
if (p) {
586+
try {
587+
const img = nativeImage.createFromPath(p);
588+
if (!img.isEmpty()) return img;
589+
} catch (_) {}
590+
}
591+
// Packaged app: .ico can fail to load from ASAR paths; Windows still reads icons embedded in the exe (packager --icon).
592+
if (process.platform === "win32" && app.isPackaged) {
593+
try {
594+
const img = nativeImage.createFromPath(process.execPath);
595+
if (!img.isEmpty()) return img;
596+
} catch (_) {}
590597
}
598+
return undefined;
591599
}
592600

593601
function resolveNotificationIcon() {

app/windows/installer-hooks.nsi

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,12 @@ Function HspClearEnvInstDir
131131
System::Call 'kernel32::SetEnvironmentVariable(t, i) ("HSP_INSTDIR", 0)'
132132
FunctionEnd
133133

134+
; PowerShell: -WindowStyle Hidden avoids flashing console windows (ExecWait still waits for exit).
134135
Function HspAnyPackagedExeRunning
135136
Call HspResolvePowerShellExe
136137
Call HspSetEnvInstDir
137138
IfFileExists "$PLUGINSDIR\hsp-app-process.ps1" 0 hspAnyExeNoScript
138-
ExecWait '"$R5" -NoProfile -ExecutionPolicy Bypass -File "$PLUGINSDIR\hsp-app-process.ps1" -Action Test' $R4
139+
ExecWait '"$R5" -NoProfile -NonInteractive -ExecutionPolicy Bypass -WindowStyle Hidden -File "$PLUGINSDIR\hsp-app-process.ps1" -Action Test' $R4
139140
Call HspClearEnvInstDir
140141
IntCmp $R4 0 hspAnyExeYes
141142
StrCpy $0 0
@@ -167,7 +168,7 @@ Function HspKillPackagedAppProcesses
167168
Call HspResolvePowerShellExe
168169
Call HspSetEnvInstDir
169170
IfFileExists "$PLUGINSDIR\hsp-app-process.ps1" 0 hspKillNoScript
170-
ExecWait '"$R5" -NoProfile -ExecutionPolicy Bypass -File "$PLUGINSDIR\hsp-app-process.ps1" -Action Kill' $R4
171+
ExecWait '"$R5" -NoProfile -NonInteractive -ExecutionPolicy Bypass -WindowStyle Hidden -File "$PLUGINSDIR\hsp-app-process.ps1" -Action Kill' $R4
171172
hspKillNoScript:
172173
Call HspClearEnvInstDir
173174
FunctionEnd

0 commit comments

Comments
 (0)