#1 11 Dec 2019 07:45

xosid
New Member
Registered: 11 Dec 2019
Posts: 2

How to pass parameter with =

Please,I want to pass value include = in parameter but when i pass this value it will be next parameter
Sample
Call test1.bat A=1

Expect
echo %1
A=1

Result
echo %1
A
echo %2
1

Offline

#2 11 Dec 2019 07:55

xosid
New Member
Registered: 11 Dec 2019
Posts: 2

Re: How to pass parameter with =

xosid wrote:

Please,I want to pass value include = in parameter but when i pass this value it split 2 parameter
Sample
Call test1.bat A=1

Expect
echo %1
A=1

Result
echo %1
A
echo %2
1

Offline

#3 12 Dec 2019 01:41

RG
Member
From: Minnesota
Registered: 18 Feb 2010
Posts: 356

Re: How to pass parameter with =

You need to quote the string like this:

Call test1.bat "A=1"

Then in test1.bat you need to use the ~ to remove the quotes like this:

echo %~1

It is good practice to almost always use quotes when passing parameters. That resolves the whitespace problem in the parameter... which you may not have now but could have in the future.


Windows Shell Scripting and InstallShield

Offline

Board footer

Powered by FluxBB