【发布时间】:2020-09-10 23:38:30
【问题描述】:
我的批处理文件是 ProcessMe.bat
命令是这样的
ProcessMe -color blue -type high --size large --tag gift
参数顺序不固定
ProcessMe -type high --tag gift --size large -color blue
ProcessMe --tag gift -color blue --size large -type high
ProcessMe --size large -type high -color blue --tag gift
和参数以相同的格式单-和双--
我想在我的 .bat 文件中读取这些参数
我尝试了这些但没有成功
echo %--size%
echo %-size%
echo %size%
echo --size
echo -size
echo size
echo %--size
echo %-size
echo %size
如何在 .bat 文件中获取参数值?!
【问题讨论】:
-
@michael_heath 这只是使用 parms 订单,在我的情况下订单是可交换的。
-
也许是Find value of command line argument in batch file 的答案。任何命令都可以。
-
我认为您将批处理参数误认为是 powershell 参数。在批处理文件中,参数通过单个
%识别的数字变量传递,例如%1其中%1是第一个参数,%2第二个等等,其中%0是批处理文件的路径. -
powershell中没有
params函数。那是一个powershell命令
标签: batch-file