0

It seems an '=' sign on an argument splits that argument into two. ie. if I have a batch file a.bat:

echo %1
echo %2

and call it using:

a 1=2

it will give as a result:

1
2

whereas I want it to give:

1=2 for the first argument.

If I put quotes around "1=2" it works however it keeps the quotes in %1.

Any idea how to get 1=2 into %1 ?

2
  • well half my comments disappeared below, why is that? Commented Sep 10, 2017 at 18:10
  • because they were comments to a now deleted answer. Commented Sep 11, 2017 at 15:27

1 Answer 1

1

To remove the surrounding quotes from an argument, include a ~.

echo %~1
Sign up to request clarification or add additional context in comments.

9 Comments

the argument doesn't have quotes: argument 1 is 1=2, I want that to go into %1
Yes, if you put "1=2" in quotes, it will work. The ~ will then remove the quotes so that %1 will hold the value 1=2 and not "1=2".
No you're missing the point, the user will not call the batch file with quotes, the user will call it with 1=2. It is my job in the batch file to interpret that correctly.
Use %* instead of %1
@Arthur It is documented, just read call /? or ss64.com/nt/syntax-args.html
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.