echo %PATH% will print the enviroment variable PATH. But I want to assign the environment variable to a batch variable first and then get the value of the environment variable. Is it possible?
Something as follows:
set myvar=PATH
echo %myvar%
The above code will echo "PATH". But I want to get the enviroment variable PATH
try with :
set myvar=PATH
call echo %%myvar%%
or with delayed expansion (it should work faster):
@echo off
set myvar=PATH
setlocal enableDelayedExpansion
echo !%myvar%!
Why you can use directly set set "myvar=%PATH%" ?
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