powershell - CMD 仅使用多个参数之一启动 .exe
问题描述
我希望我的批处理脚本在没有我输入的情况下自行随机选择一个参数(从大约 70 个参数中,例如 param1 - param70)。
除了随机参数外,exe 还有更多参数始终保持不变。
我不知道如何将其放入代码中。
这是我的想法的一个例子:
param1=--abc
param2=--mno
param3=--xyz
./example.exe --hello --world --(param1 OR param2 OR param3)
等于:
./example.exe --hello --world --abc
或者
./example.exe --hello --world --mno
或者
./example.exe --hello --world --xyz
解决方案
这可以批量工作。不过,您需要设置每个参数。
set /a numb=%random% %% 3
goto :param%numb%
:param0
Set "var=abc"
Goto :execute
:param1
Set "var=mno"
Goto :execute
:param2
Set "var=xyz"
Goto :execute
:execute
.\example.exe --hello --%var%
对于 70 参数,您需要更改%% 3
为%% 70
推荐阅读
- ios - CLLocationManager:allowDeferredLocationUpdates - 不断获取操作无法完成。(kCLErrorDomain 错误 11。)
- npm - 当我将 Foundation 6 用于电子邮件时,Sass 不起作用
- c - 如何在结构中使用冒泡排序 / qsort() 按字母顺序排序
- angularjs - 快速路由提供 angularjs 内容但不提供 api
- lua - 对这段 Python 使用 Lua 表的最优雅的解决方案
- apache-spark - 如何将 Spark 应用程序 jar 文件部署到 Kubernetes 集群?
- purescript - 虚空荒诞是如何运作的
- animation - 如何在 JavaFX 中更改 AnimationTimer 的速度?
- ruby - ruby 如何停止用户输入的循环?
- javascript - 为什么我的分数变量没有显示正确的值?