0

So the title may not be very explicit about what I'm looking for, but basically I have this code:

echo python %2 "%1" >> activate_wrapper.bat

This code is inside a .bat file and it's purpose is to build another .bat file that will run a python script. Thing is I don't want to write the value of %1 to activate_wrapper.bat, I want to write the string "%1".

Expected line in activate_wrapper.bat:

python secondArg %1

What am I getting:

python secondArg "firstArg"

Thanks in advance guys.

SOLUTION:

echo python %2 %%1 >> activate_wrapper.bat
1
  • Have you tried %%1 ?
    – Neil
    Commented Apr 27, 2017 at 10:36

1 Answer 1

2

The computer cannot read your mind, it doesn't know you only want to expand one of the parameters!

You must escape the % to prevent expansion:

echo hello %2 "%%1" >> temp.txt
set something=whatever
echo hello %%something%% >> temp.txt

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.