Skip to content

Fix elevated launcher quoting for unusual paths - #11

Open
css521 wants to merge 1 commit into
ekalb81:mainfrom
css521:fix/admin-launcher-quoting
Open

Fix elevated launcher quoting for unusual paths#11
css521 wants to merge 1 commit into
ekalb81:mainfrom
css521:fix/admin-launcher-quoting

Conversation

@css521

@css521 css521 commented Aug 21, 2026

Copy link
Copy Markdown

Summary

  • move the elevation handoff into a PowerShell helper invoked with -File and a bound -ScriptPath parameter
  • quote the child PowerShell.exe argument line using Windows argv rules, preserving spaces, apostrophes, ampersands, parentheses, Unicode, and trailing backslashes
  • keep the visible UAC prompt and preview-only behavior; propagate missing-script and elevation failures as non-zero exits
  • document the launcher behavior and add regression coverage that does not display UAC

Testing

Run on Windows 11 with Windows PowerShell 5.1:

  • Invoke-Pester -Path .\tests\Run-PATH-Repair-Admin.Tests.ps1 — 12 passed, 0 failed
  • Invoke-Pester -Path .\tests — 28 passed, 0 failed
  • git diff --check — passed

The regression tests cover a path containing spaces, an apostrophe, &, parentheses, and Chinese characters; validate parsing with CommandLineToArgvW; exercise a real non-elevated child process and the CMD-to-PowerShell handoff; and verify missing-target and elevation-failure behavior. Restoring the original batch launcher makes two of the new regression tests fail, confirming they detect the reported bug.

Fixes #5

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.

Harden Run-PATH-Repair-Admin.bat argument quoting for unusual repository paths

1 participant