Remove cli.js argument when running as administrator on Windows#296690
Merged
joaomoreno merged 5 commits intomainfrom Feb 23, 2026
Merged
Remove cli.js argument when running as administrator on Windows#296690joaomoreno merged 5 commits intomainfrom
joaomoreno merged 5 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request fixes a Windows-specific issue where cli.js appears as a stray argument when VS Code is configured to run as administrator. The issue occurs because the CLI launcher (code.cmd) sets the ELECTRON_RUN_AS_NODE=1 environment variable, but when the process is elevated, the environment variable is not inherited. This causes Electron to start as a GUI application with cli.js as an unintended positional argument.
Changes:
- Added logic to detect and strip the stray
cli.jsargument on Windows before parsing command-line arguments - Added necessary imports for path manipulation (
dirname,resolve) and platform detection (isWindows)
|
Thank you for doing this! |
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: @bpaseroMatched files:
|
joaomoreno
approved these changes
Feb 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #91613
Changes
Ignore the first cli.js argument on Windows when its full path matches one under VS Code installation location.
Notes
with this change commands like "code ." will work and elevated VS Code will open the folder without opening cli.js. This change does not elevate the CLI and it still won't run in this scenario - if elevated CLI is needed, the command needs to be ran from an elevated command prompt.
Validation
With official build and VS Code set to run in admin mode, verified starting VS Code from non-elevated command line does not open cli.js but opens the folder passed in.