If a user were to input: "program.bat --execute -s 1000 -r 60"
如果用户要输入:“program.bat --execute -s 1000 -r 60”
How can I extract the input as one string starting from "-s" to the end (the end could have unlimited number of parameters). In this case, I'd want "-s 1000 -r 60".
如何将输入提取为从“-s”开始到结尾的一个字符串(结尾可以有无限数量的参数)。在这种情况下,我想要“-s 1000 -r 60”。
I want to do something like:
我想做的事情如下:
if "%1"=="--execute"
grab the rest of the arguments
I know %* grabs all the arguments, but I only want -s till the end.
我知道%*抓住了所有的参数,但我只想要-s直到最后。
1 个解决方案
#1
You already know that %*
starts with --execute
, so it is safe to delete everything up through the first occurrance of --execute
.
您已经知道%*以--execute开头,因此在第一次出现--execute时删除所有内容是安全的。
set args=%*
if %1 equ --execute echo args=%args:*--execute=%
#1
You already know that %*
starts with --execute
, so it is safe to delete everything up through the first occurrance of --execute
.
您已经知道%*以--execute开头,因此在第一次出现--execute时删除所有内容是安全的。
set args=%*
if %1 equ --execute echo args=%args:*--execute=%