Page 1 of 1

why doesn't this setting and displaying environment variable work?

Posted: 30 Jan 2020 03:36
by taripo
been a while since I used batch files, I tend to use them very rarely and don't tend to remember some of the idiosyncracies and I try some tests to figure them out but this simple one has me stuck.

why doesn't this setting and displaying environment variable work?

Code: Select all

C:\blah>type testenvv.bat

set %%ppp%%="tgt"
set %ppp%="tgt"
echo %%ppp%%
echo %ppp%

C:\blah>

Code: Select all

C:\blah>testenvv.bat

C:\blah>set %ppp%="tgt"

C:\blah>set ="tgt"
The syntax of the command is incorrect.

C:\blah>echo %ppp%
%ppp%

C:\blah>echo
ECHO is on.
Thanks

Re: why doesn't this setting and displaying environment variable work?

Posted: 31 Jan 2020 10:16
by jfl
The correct syntax is:

Code: Select all

set ppp="tgt"
echo %ppp%

Re: why doesn't this setting and displaying environment variable work?

Posted: 31 Jan 2020 14:13
by taripo
doh!

Thanks!