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:

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

My output is:

<Missing the ^>

Might I need to escape the ()'s somehow?
Who is Participating?
Either use four "^":
SET location=P%%@AP[4\PZX54(P^^^^)7
ECHO %location%

Open in new window

Or use two and put part after the SET command in double quotes:
SET "location=P%%@AP[4\PZX54(P^^)7"
ECHO %location%

Open in new window

stakorAuthor Commented:
Thank you. I would not have thought to use four of them.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.