|
Answer» I want to pass a string contains the comma, such as "A,B,C", to the DOS batch file. I want the whole string to be treated as ONE, not THREE separated parameters, how can I accomplish this?
thanksexplain further, what COMMAND are using the delims with ?This any use?
Quote C:\>type testme.bat @echo off echo a,b,c > test.txt echo d,e,f >> test.txt echo H,i,j >> test.txt
for /f "delims==" %%L in (test.txt) do ( echo %%L )
C:\>testme.bat a,b,c d,e,f h,i,j
here is the example:
Quote> type test.bat @echo off
external_program /para:"%1"
What I expect is:
test A,B,C
the batch file will call that external program in the format of external_program /para:"A,B,C"Quote from: OldJack on October 13, 2007, 10:38:32 AMhere is the example:
Quote> type test.bat @echo off
external_program /para:"%1"
What I expect is:
test A,B,C
the batch file will call that external program in the format of external_program /para:"A,B,C"
OK I'm with you now.
First add quotes
test "a,b,c"
Then remove them with the ~ modifier in the batch file if you need to or just LEAVE them.
Quote
C:\>type test2.bat @echo off echo %1 echo %~1 echo "%~1" echo external_program /para:"%~1" echo external_program /para:%1
C:\>test2.bat a,b,c a a "a" external_program /para:"a" external_program /para:a
C:\>test2.bat "a,b,c" "a,b,c" a,b,c "a,b,c" external_program /para:"a,b,c" external_program /para:"a,b,c"
Excellent! Thanks.
Quote
C:\>type test2.bat @echo off echo %1 echo %~1 echo "%~1" echo external_program /para:"%~1" echo external_program /para:%1
C:\>test2.bat a,b,c a a "a" external_program /para:"a" external_program /para:a
C:\>test2.bat "a,b,c" "a,b,c" a,b,c "a,b,c" external_program /para:"a,b,c" external_program /para:"a,b,c"
|