Skip to content

fix(updater): make the Windows swap script survive non-ASCII paths - #870

Merged
marcinz606 merged 1 commit into
marcinz606:mainfrom
MohammedAlkindi:fix/nsis-script-codepage
Aug 17, 2026
Merged

fix(updater): make the Windows swap script survive non-ASCII paths#870
marcinz606 merged 1 commit into
marcinz606:mainfrom
MohammedAlkindi:fix/nsis-script-codepage

Conversation

@MohammedAlkindi

Copy link
Copy Markdown
Contributor

On Windows the in-app updater writes its swap script as a UTF-8 .bat, but cmd.exe parses a batch file in the OEM codepage. The installer is staged under %TEMP%, whose path carries the account name, so for a user whose account name has a non-ASCII character every path decodes wrong: start cannot find the installer, nothing installs, and explorer cannot relaunch the app. The update silently does nothing.

Putting chcp 65001 on the first line after @echo off fixes it: pure ASCII, so it parses the same under any codepage, and cmd reads the rest as the UTF-8 the file is written in. The POSIX scripts are untouched.

Verified on Windows 11 (OEM cp437) through a ShellExecuteW-spawned console: an accented staging path resolves the installer only with the prologue present. Every line after the chcp switch still ran, so the old pre-1903 chcp 65001 parsing regression does not bite on the Windows 10 and 11 builds NegPy targets. A full elevated install needs a signed build and admin, so this confirms the path resolution, not the install downstream.

cmd.exe parses a batch file in the console OEM codepage, but
_spawn_elevated_bat writes it as UTF-8. The staging path under %TEMP%
carries the profile name, so for any user whose Windows account name
has a non-ASCII character every path line in the swap script garbles:
start cannot find the downloaded installer, nothing installs, and
explorer cannot restart the app. Self update silently does nothing.

Put `chcp 65001 >nul` on the first line after `@echo off`. That line
is pure ASCII, so it parses identically under any codepage, and every
line after it is read as the UTF-8 the file is actually written in.

Verified on Windows 11 (OEM cp437) with a ShellExecuteW-spawned
console: a batch referencing an accented path, written UTF-8 the way
_spawn_elevated_bat writes it, reports the file missing; with the
prologue the same file is found.
@marcinz606
marcinz606 merged commit 608361a into marcinz606:main Aug 17, 2026
1 check passed
activexray pushed a commit to activexray/NegPy that referenced this pull request Aug 17, 2026
…arcinz606#870)

cmd.exe parses a batch file in the console OEM codepage, but
_spawn_elevated_bat writes it as UTF-8. The staging path under %TEMP%
carries the profile name, so for any user whose Windows account name
has a non-ASCII character every path line in the swap script garbles:
start cannot find the downloaded installer, nothing installs, and
explorer cannot restart the app. Self update silently does nothing.

Put `chcp 65001 >nul` on the first line after `@echo off`. That line
is pure ASCII, so it parses identically under any codepage, and every
line after it is read as the UTF-8 the file is actually written in.

Verified on Windows 11 (OEM cp437) with a ShellExecuteW-spawned
console: a batch referencing an accented path, written UTF-8 the way
_spawn_elevated_bat writes it, reports the file missing; with the
prologue the same file is found.
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.

2 participants