Skip to content

win32(installer): Normalize PATH handling and fix uninstall filtering [needs testing]#264219

Open
yugook wants to merge 3 commits intomicrosoft:mainfrom
yugook:fix/win32-installer/path-env-trim
Open

win32(installer): Normalize PATH handling and fix uninstall filtering [needs testing]#264219
yugook wants to merge 3 commits intomicrosoft:mainfrom
yugook:fix/win32-installer/path-env-trim

Conversation

@yugook
Copy link
Copy Markdown

@yugook yugook commented Aug 31, 2025

⚠️ This PR updates PATH handling logic in the Windows installer.
Changes are verified with string-based tests (PowerShell), but I would appreciate further testing on real Windows setups.

Summary

Normalize PATH handling in the Windows installer (build/win32/code.iss) and fix uninstall filtering:

  • Trim trailing separators when comparing (\ and /)
  • Case-insensitive comparison
  • Consider 8.3 short names (when available)
  • Handle empty / semicolon-terminated PATH without producing malformed values

Why

  • Avoid duplicate PATH entries when the existing entry has a trailing slash or is in 8.3 short form.
  • Ensure uninstall removes VS Code’s PATH entry (both long and short forms).

How

  • Add TrimTrailingSlash helper.
  • NeedsAddToPath: explode PATH, normalize each segment, compare against long and short names.
  • AddToPath: treat empty/absent PATH specially; respect trailing ;.
  • Uninstall: normalize {app}\bin, compare against both long/short, rebuild PATH cleanly.

Before / After (examples)

  • Before: PATH contains …;C:\Program Files\Microsoft VS Code\bin\ → installer adds …;C:\Program Files\Microsoft VS Code\bin (duplicate).
  • After: no duplicate added.
  • Before: PATH contains …;C:\PROGRA~1\MICROS~1\bin → uninstall sometimes leaves it behind.
  • After: long/short both removed.

Verification

  • Windows Sandbox, PowerShell dry-run (strings only; no system writes):
    • trailing slash present → NeedsAddToPath: False; RemoveFromPath: entry removed
    • 8.3 short present → NeedsAddToPath: False; RemoveFromPath: entry removed
    • empty PATH → AddToPath: C:\Program Files\Microsoft VS Code\bin
    • PATH ends with ; → no malformed value produced
      (Full installer tests can be run if preferred.)

Risk / Impact

Low: changes are isolated to installer script and guarded when 8.3 names are not available.

@yugook
Copy link
Copy Markdown
Author

yugook commented Aug 31, 2025

@microsoft-github-policy-service agree

@yugook yugook marked this pull request as ready for review August 31, 2025 13:51
@bpasero bpasero assigned joaomoreno and deepak1556 and unassigned Tyriar Sep 22, 2025
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.

5 participants