When I'm logged in with my standard user (which is also an admin) the command echo %PATH%
returns system's path + user's path. How can I get the user's path only?
E.g. when my current user's path is C:\ruby;C:\java\bin
and system's path is %SystemRoot%\system32;%SystemRoot%
the command above returns %SystemRoot%\system32;%SystemRoot%;C:\ruby;C:\java\bin
but I only want to have C:\ruby;C:\java\bin
in order to be able to append to user's path permanently without system's path trash included.
My goal is to append a directory to the path variable. I tried to do this with the command setx PATH %PATH%;C:\ruby\bin
which ruined my path variable because of the system's path.
Another way using PowerShell.
(Get-ItemProperty HKCU:\Environment).PATH
Or, from a cmd.exe shell.
powershell -NoProfile -Command "(Get-ItemProperty HKCU:\Environment).PATH"
In order to retrieve the variable without interpolation.
(Get-Item -Path HKCU:\Environment).GetValue('PATH', $null, 'DoNotExpandEnvironmentNames')
powershell -NoProfile -Command ^
"(Get-Item -Path HKCU:\Environment).GetValue('PATH', $null, 'DoNotExpandEnvironmentNames')"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With