将带有空格的参数传递给批处理文件
我确信答案就像将“”传递给批处理文件中的参数一样简单。但这失败了。这就是我正在尝试做的事情。
Test.bat env "Some cmd"
这个“Some cmd”是另一个需要在env设置的环境中运行的命令。
Test.bat:
Something like set Env with %1%
set cmd=%2%
%cmd%
以上失败,并显示“某些 cmd”未被识别为 cmd。
我可以让它工作的唯一方法是在批处理文件中使用“%cmd%”。这是对的吗?
I am so sure answer is as simple as passing "" to the arguments in batch file. But this fails. Here is what I am trying to do.
Test.bat env "Some cmd"
This "Some cmd" is another command that needs to run in environment set by env.
Test.bat:
Something like set Env with %1%
set cmd=%2%
%cmd%
The above fails with '"Some cmd"' is not recognized as a cmd.
Only way I can get this to work is if I use "%cmd%" in batch file. Is this right?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您需要指定“Some cmd”所在的路径。
I think you need to specify path where "Some cmd" is present.