Reputation: 83
Say for example in Control Panel\System and Security\System > Advanced System Settings > System Properties > Advanced Tab > Environment variables...
I have the following PATH:
Value 1:
PATH=%JAVA_HOME%\bin;e:\Groovy\GROOVY~1.0\bin;E:\Python;C:\Users\MyName\AppData\Local\GitHubDesktop\bin;%PYTHON3_HOME%;%GROOVY_HOME%\bin;
when in cmd, I do:
echo %PATH%
then I get:
Value 2:
E:\Program Files\Java\jdk1.8.0_151\bin;e:\Groovy\GROOVY~1.0\bin;C:\Users\MyName\AppData\Local\GitHubDesktop\bin;E:\Program Files\Python\Python36-32;E:\Program Files (x86)\Groovy\Groovy-2.6.0\bin;
Then what command in cmd will be able to print out same exact PATH values with variable names (%JAVA_HOME% etc.) as from the System Properties (Value 1)?
Upvotes: 4
Views: 43245
Reputation: 11
From cmd, try this :
powershell gci env:<name_variable>
Example : powershell gci env:Path
If you want all variables name starting (or finishing) with Path just add *
after (or before) your variable name.
Example : powershell gci env:*Path*
:-)
Upvotes: 1
Reputation: 82307
The set <variableName>
command shows variables without interpreting the content.
Or you can ise delayed expansion for that, too.
setlocal EnableDelayedExpansion
echo !path!
but in your case, the expansion in echo %path%
will not expand any further percent parts in the content of PATH (you get only problems with other characters like &|<>
)
The content is already expanded after you set the path with set PATH=%JAVA_HOME%\bin
.
When you set the percent part instead of the expanded version, then the PATH
searching doesn't work anymore, as cmd.exe would try to search in the literal path of %JAVA_HOME%
To get the definition of the PATH from the System Properties can be retrieved from the registry via REG QUERY
.
User variables with
reg query HKEY_CURRENT_USER\Environment /v path
And the system variables with
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v path
Upvotes: 3