Windows Store version can't modify PATH
See original GitHub issueSteps to reproduce
PS> $path = [Environment]::GetEnvironmentVariable('Path', 'User)
PS> $newPath = "<add new entry here>;$path"
PS> [Environment]::SetEnvironmentVariable('Path', $newPath, 'User')
Expected behavior
User’s PATH content is altered and verifiable through System Properties > Environment Variables
Actual behavior
PowerShell 7 reports the new value for the User’s PATH.
User’s PATH remains the same on every software (Windows PowerShell, for example) and System Properties > Environment Variables.
Example, showing C:\Users\bruno\foo
is on my PATH (I’ve added it using steps documented above) according to PowerShell 7 downloaded from Microsoft Store:
PS> [Environment]::GetEnvironmentVariable('Path', 'User')
C:\Users\bruno\foo;C:\Users\bruno\scoop\apps\gpg\current\bin;C:\Users\bruno\scoop\apps\nodejs\current\bin;C:\Users\bruno\scoop\apps\nodejs\current;C:\Users\bruno\scoop\shims;C:\Users\bruno\AppData\Local\Microsoft\WindowsApps;C:\Users\bruno\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\bruno\AppData\Local\Programs\Azure Data Studio\bin
If I go to System Properties, PATH is different, not showing the path I added through PS7:
Some important notes:
- New value is always shown in PowerShell 7 only
- This does not occur with PS 7 installed through MSI, only MS Store version
- This happens independently of Terminal used (ConHost and Windows Terminal tested)
- Occurs even after launching a new instance (of Windows Terminal AND PS 7, tested that)
- New PATH is never shown in System Properties or Windows PowerShell, even after launching new instances, logging out or rebooting the PC
- Only way to revert the PATH on PS 7 (so it has the same value as the System Properties one) is editing it through PS 7, as no other way contains the bugged content
Environment data
Name Value
---- -----
PSVersion 7.1.2
PSEdition Core
GitCommitId 7.1.2
OS Microsoft Windows 10.0.19042
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:12 (1 by maintainers)
Top Results From Across the Web
Can't change Windows Store install location because of old ...
Right click on the folder, then go to Properties. Go to the Security tab, click on Edit to open the Permission for <Object>...
Read more >Can't change environment variables in windows 10
In Windows 10 version 1607 the environment variable PATH is updated when you enter the full path to a command within the Windows...
Read more >I can't change the Apps directory where I install Windows ...
Hi ! I wanted to install the Nvidia Control Panel from the Store and it needs to be installed on the system drive....
Read more >Unable to change system variable path in Windows 10 as ...
I got around it by opening the System page in Control Panel (Win+X -> Y), going to "Advanced system settings", then clicking "Environment ......
Read more >How can I modify a user's PATH environment variable ...
On Windows 10, a user without administrator privileges can edit their own path variable by going to Settings and searching for "Edit environment ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@brunovieira97 @vexx32 Yes thank you. Powershell calls cmd.exe and others think of it as a shortcut to exe files on windows. The ps command and the code should be
PS> [Environment]::GetEnvironmentVariable(‘Path’, ‘System’) PS> [Environment]::SetEnvironmentVariable(‘Path’, ‘System’) To set system paths.
Windows Store apps are sandboxed, by design. PowerShell 7 store app explicitly requests unvirtualized resources which should include registry (that’s where
PATH
is persisted), but seems like this isn’t being honored. Will have to follow-up with the AppX folks.