Link to home
Start Free TrialLog in
Avatar of stakor
stakorFlag for United States of America

asked on

Trouble with a special character in a batch file variable

I am having trouble with a variable in a batch file. I am setting a variable with special characters, and having trouble getting them to print.

One of the two special characters is %. That one, I got to print by putting two of them in the variable. (aka % became %%) The other character is ^. I have seen that ^^ should work. But, it does not.

The (literal) string that should print is:
P%@AP[4\PZX54(P^)7

Batch file I am using:
@ECHO OFF
SET location=P%%@AP[4\PZX54(P^^)7
ECHO %location%

My output is:
P%@AP[4\PZX54(P)7

<Missing the ^>

Might I need to escape the ()'s somehow?
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of stakor

ASKER

Thank you. I would not have thought to use four of them.