Type environmental variable that doesn't exist

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
batchcc
Posts: 139
Joined: 17 Aug 2015 06:05
Contact:

Type environmental variable that doesn't exist

#1 Post by batchcc » 30 Nov 2015 14:10

I have the following batch code

Code: Select all

@echo off
cls
echo enter first word
set /p a=
echo enter second word
set /p b=
@echo off
@echo if %word% == %a% echo to %b% ----- %c%>> c.txt
@echo if %word% == %b% echo to %a% ----- %c%>> c.txt
goto top

unfortunately the environmental variables %word% and %c% don't get typed because they don't exist in this file how can I type them into the text file?
this is what gets written to the file

Code: Select all

if  == hello echo to bye ----- 
if  == bye echo to hello -----

penpen
Expert
Posts: 2009
Joined: 23 Jun 2013 06:15
Location: Germany

Re: Type environmental variable that doesn't exist

#2 Post by penpen » 30 Nov 2015 14:26

I'm not sure if this is what you want to do:

Code: Select all

echo if %%word%% == %a% echo to %b% ----- %%c%%>> c.txt
echo if %%word%% == %b% echo to %a% ----- %%c%%>> c.txt


penpen

Post Reply