📎 AI Summary:
The forum discussion addresses challenges with comparing string parameters containing equal signs in batch scripts. The original poster struggles with quoting issues that cause errors during comparison, but finds that using the `%~1` syntax to remove quotes resolves the problem. Responders suggest avoiding quotes in comparisons, recommend alternative scripting languages like PowerShell or Python for easier handling, and offer to assist with rewriting the script in PowerShell. Overall, the community shares solutions and alternative approaches to improve script robustness.

eldiener

Honorable Member
Joined
Nov 17, 2012
Messages
35
Thread Author #1
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
Thread Author #3
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,995
If you PM your script I'd be happy to re-write it in powershell.