eldiener

Honorable Member
Joined
Nov 17, 2012
Messages
35
In a batch file I have a line such as:

if "%1" == "some_value" goto somegoto

in order to test a parameter against a value. If however I need to pass as the first parameter to my batch file a string with some equal signs in it such as:

"cxxflags=-std=c++11"

I pass it with quotes so it is a single parameter, else batch file processing will split it on the various equal signs in the parameter. However when it processes this single batch parameter in my statement above I get the message:

=-std=c++11"" was unexpected at this time on the line in the batch file of:

if ""cxxflags=-std=c++11"" == "some_value" goto somegoto

How can I get the batch file to make the comparison correctly ? It obviously doesn't like the form of comparison of:

if "%1" == "some_string"

when %1 is itself a quoted string with an equal sign in it.
 

Solution
Thanks !

Powershell docs have always seemed very poor to me. If I really want something better I use Python. Using the
%~1 syntax solved my problem in the batch file.

eldiener

Honorable Member
Joined
Nov 17, 2012
Messages
35
Thanks !

Powershell docs have always seemed very poor to me. If I really want something better I use Python. Using the
%~1 syntax solved my problem in the batch file.
 

Solution

Neemobeer

Windows Forum Team
Staff member
Joined
Jul 4, 2015
Messages
8,998
If you PM your script I'd be happy to re-write it in powershell.