The goal is to take the following array in a windows .bat file:
目标是在Windows .bat文件中采用以下数组:
set SEARCH_DIR[1]="SomeValue"
set SEARCH_DIR[2]="AnotherValue"
set SEARCH_DIR.length=2
And to execute for example "someprogram.exe" with the values of SEARCH_DIR passed as individual command line arguments. I would prefer to do this as a loop or something rather than have to manually type out each element in SEARCH_DIR.
并执行例如“someprogram.exe”,其值为SEARCH_DIR作为单独的命令行参数传递。我宁愿这样做作为循环或其他东西,而不是必须手动键入SEARCH_DIR中的每个元素。
I found similar questions but none that answered it example. Thanks in advance.
我发现了类似的问题,但没有一个回答它的例子。提前致谢。
1 个解决方案
#1
1
If you don't find an example matching 100 percent
you could try on your own, that is what programmers do.
如果你没有找到一个匹配百分之百的例子你可以自己尝试,那就是程序员所做的。
@Echo off&SetLocal EnableExtensions EnableDelayedExpansion
set SEARCH_DIR[1]="SomeValue"
set SEARCH_DIR[2]="AnotherValue"
set SEARCH_DIR.length=2
Set "AllArgs="
For /L %%C in (1,1,%SEARCH_Dir.length%
) Do Set AllArgs=!AllArgs! !SEARCH_DIR[%%C]!
Echo someprogram.exe %AllArgs%
#1
1
If you don't find an example matching 100 percent
you could try on your own, that is what programmers do.
如果你没有找到一个匹配百分之百的例子你可以自己尝试,那就是程序员所做的。
@Echo off&SetLocal EnableExtensions EnableDelayedExpansion
set SEARCH_DIR[1]="SomeValue"
set SEARCH_DIR[2]="AnotherValue"
set SEARCH_DIR.length=2
Set "AllArgs="
For /L %%C in (1,1,%SEARCH_Dir.length%
) Do Set AllArgs=!AllArgs! !SEARCH_DIR[%%C]!
Echo someprogram.exe %AllArgs%