Solved Outputting text surrounded in %'s without translating to var

January 19, 2013 at 20:56:45
Specs: Windows 7/8
Is there a way to echo text surrounded in %
without it being translated into a variable?

I am basically trying to do this:

echo if %computername% == SomeComputer set AuthChk=1 >> BatchFile.cmd


See More: Outputting text surrounded in %s without translating to var

Report •


✔ Best Answer
January 19, 2013 at 21:54:32
I thinkthe double percents should take care of it. You're using a batch to write another batch, (which is usually not necessary - ie: there may be better approaches to the main objective), but... so this should handle what you've described, (even works inside of quotes):
echo if "%%computername%%" == "computerA" call :compA >> batchfile.cmd

crossed in the mail.



#1
January 19, 2013 at 21:06:58
echo %%testing%%

Report •

#2
January 19, 2013 at 21:39:59
Say %computername% = ComputerA

I want the output text to appear as:
if %computername% == ComputerB (Action)

NOT as:
if ComputerA == ComputerB (Action)

OR
if %ComputerA% == ComputerB (Action0


Report •

#3
January 19, 2013 at 21:41:23
(See other comment)

Report •

Related Solutions

#4
January 19, 2013 at 21:51:26
I figured it out

set var=computername
echo if %%var%% == ComputerB (action)


Report •

#5
January 19, 2013 at 21:54:32
✔ Best Answer
I thinkthe double percents should take care of it. You're using a batch to write another batch, (which is usually not necessary - ie: there may be better approaches to the main objective), but... so this should handle what you've described, (even works inside of quotes):
echo if "%%computername%%" == "computerA" call :compA >> batchfile.cmd

crossed in the mail.


Report •

#6
January 20, 2013 at 23:34:00
BTW,

Putting spaces before and after == is a recipe for trouble.

=====================
M2 Golden-Triangle


Report •

#7
January 21, 2013 at 03:58:56
Mechanix2Go, It is? Why?

Report •

#8
January 22, 2013 at 00:14:34
In this:

if a == a

resolves to:

a[space]==[space]a

They are not the same.

=====================
M2 Golden-Triangle


Report •

Ask Question