(#3829) Enhance RefreshEnv.cmd to capture volatile variables#3830
Open
revoconner wants to merge 1 commit intochocolatey:developfrom
Open
(#3829) Enhance RefreshEnv.cmd to capture volatile variables#3830revoconner wants to merge 1 commit intochocolatey:developfrom
revoconner wants to merge 1 commit intochocolatey:developfrom
Conversation
Add handling for additional volatile environment variables (APPDATA, LOCALAPPDATA, USERPROFILE, HOMEDRIVE, HOMEPATH) that should not be overwritten when refreshing from registry. Without this change, these user-specific paths get incorrectly reset to system defaults when running RefreshEnv.cmd.
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.
Description Of Changes
Added preservation of additional volatile environment variables
(APPDATA, LOCALAPPDATA, USERPROFILE, HOMEDRIVE, HOMEPATH)that should not be overwritten when refreshing from registry. These are captured before calling the generated_env.cmdand restored afterward, matching the existing pattern for USERNAME and PROCESSOR_ARCHITECTURE.Motivation and Context
This is the same class of bug as #3681 (fixed for TEMP/TMP in v2.6.0). When
HKCU\Environmentcontains incorrect entries for volatile variables,refreshenvoverwrites the session's correct values. In my case, an incorrect APPDATA entry caused VS Code to create its data directory in the wrong location (AppData\Codeinstead ofAppData\Roaming\Code).Windows generates these volatile variables at login and they should not be overwritten from potentially stale or incorrect registry entries.
Testing
HKCU\EnvironmentrefreshenvOperating Systems Testing
Change Types Made
Change Checklist
Related Issue
Fixes #3829