Link to home
Start Free TrialLog in
Avatar of Vadim Rapp
Vadim RappFlag for United States of America

asked on

Batch file: how to call <label> with parameter with & inside?

I have this batch:
set p=abcde
call :mysub %p%
exit /b
:mysub
echo %1

Open in new window

and it works as expected. But if instead of abcde I have a string with & inside,
set p=ab&de
call :mysub %p%
exit /b
:mysub
echo %1

Open in new window

it does not work, as I understand because & is interpreted as escape character. I tried to put various numbers of ^ before & in line 1, but nothing works.

How to get it to work so parameter %1 gets the actual string ab&cd ?
Avatar of Randy Poole
Randy Poole
Flag of United States of America image

Give this a try
set p=ab^&de
call :mysub %p%
exit /b
:mysub
echo %1

Open in new window

SOLUTION
Avatar of Steve Whitcher
Steve Whitcher

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
ASKER CERTIFIED SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

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