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

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
taripo
Posts: 227
Joined: 01 Aug 2011 13:48

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

#1 Post by taripo » 30 Jan 2020 03:36

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

jfl
Posts: 226
Joined: 26 Oct 2012 06:40
Location: Saint Hilaire du Touvet, France
Contact:

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

#2 Post by jfl » 31 Jan 2020 10:16

The correct syntax is:

Code: Select all

set ppp="tgt"
echo %ppp%

taripo
Posts: 227
Joined: 01 Aug 2011 13:48

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

#3 Post by taripo » 31 Jan 2020 14:13

doh!

Thanks!

Post Reply