is there an escape for '&' character in the command prompt?

What you need to do is wrap your password in double quotes like so:

set pwd="abc&123"
echo %pwd%

Let me know how it goes.


I found that it works best with a combination of both martineau's answer and mastashake57's answer.

set pwd=abc^&123
echo %pwd%

Still fails, and

set pwd="abc&123"
echo %pwd%

Adds quotes to it (you can't remove the quotes with a for loop or string manipultaion because it will fail again, thanks to the ampersand), which isn't that great.

However,

set "pwd=abc^&123"
echo %pwd%

Works perfectly.

Hope that helps.