Batch file 用于分析范围内的输入参数的Windows批处理命令
如果用户要输入:program.bat-execute-s1000-r60 如何将输入提取为一个字符串,从-s开始到结尾。结尾可以有无限数量的参数。在这种情况下,我想要-s1000-r60 我想做一些类似的事情:Batch file 用于分析范围内的输入参数的Windows批处理命令,batch-file,args,Batch File,Args,如果用户要输入:program.bat-execute-s1000-r60 如何将输入提取为一个字符串,从-s开始到结尾。结尾可以有无限数量的参数。在这种情况下,我想要-s1000-r60 我想做一些类似的事情: if "%1"=="--execute" grab the rest of the arguments 我知道%*会获取所有参数,但我只希望-s一直到最后。您已经知道,%*以-execute开头,因此在-execute第一次出现时删除所有参数是安全的 这是公认的答案对你没有帮
if "%1"=="--execute"
grab the rest of the arguments
我知道%*会获取所有参数,但我只希望-s一直到最后。您已经知道,%*以-execute开头,因此在-execute第一次出现时删除所有参数是安全的
这是公认的答案对你没有帮助吗?我什么都不知道。我会编写一个小型实用程序来处理%*字符串,或者使用正则表达式处理器。
set args=%*
if %1 equ --execute echo args=%args:*--execute=%