David_Garcia
David_Garcia

Reputation: 654

Pass parameters with special characters in batch

I have a script file that can receive some arguments on this way:

echo --debug will run the tests but not run the installer. This need to be the first parameter.
echo --testcases=TESTCASES Provide a list of testcases to execute instead of those in App.config. The TESTCASES list commma-separated.
echo --dbkeys=DATABASEKEYS Provide a list of UTDB keys to prepare instead of those in App.config. The DB keys in question must be a subset of those mentioned in App.config. The DATABASEKEYS list should be commma-separated.

So for example you can call this file ./file.bat --testcases="test1, test2" --dbkeys="db1" This part work fine because in the script I have this call: call Test\MidTierLibUT\bin\Release\FleetManagerAPI.MidTierLibUT.exe %* || exit /b -2 but if I put as first parameter --debug, I want to do different things before I call call Test\MidTierLibUT\bin\Release\FleetManagerAPI.MidTierLibUT.exe %* || exit /b -5 and in the %* I will like to not have there --debug passing.

So I tried:

shift
:start
if [%1] == [] goto done
set args=%args% %~1
shift
goto start

:done
call Test\MidTierLibUT\bin\Debug\FleetManagerAPI.MidTierLibUT.exe %args% || exit /b -5

but %args% will look like: --testcases test1 test2 (with no " or = )

someone can help me please?

Upvotes: 0

Views: 86

Answers (1)

David_Garcia
David_Garcia

Reputation: 654

I thought a little out the box trying to find the solution and with the ideas of @aschipfl and @SomethingDark I figurate that it was easier to remove that part of the string all together and send the rest :) So the solution is something like:

set args=%*
set args= %args:--debug=%
Test\MidTierLibUT\bin\Debug\FleetManagerAPI.MidTierLibUT.exe %args% || exit /b -5

Thanks for the help!

Upvotes: 1

Related Questions