I want to invoke a batch file with a comma-delimited paramater. How can I achieved this?
I want it like this example.
I have a text.bat with the script:
@echo off
set test=%1
echo Sample %test% batch.
I want to run the batch like this:
c:\text.bat this,is,sample
and I am expecting a result like this:
Sample this,is,sample batch.
Any idea how I could achieve this?
Thanks.
Wow! I didn't know commas behaved that way.
You have two options.
You can use this script:
@echo off
set test=%~1
echo Sample %test% batch.
And run it with:
C:\text.bat "this,is,test"
The %~1
represents the first argument without quotes. The quotes group the comma-delimited list as a single argument.
Or
You can use this script:
@echo off
set test=%*
echo Sample %test% batch.
And run it with:
C:\text.bat this,is,test
The %*
represents the command line arguments as they were typed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With