在批处理文件中传递第二个参数 [英] passing a second parameter in a batch file

查看:148
本文介绍了在批处理文件中传递第二个参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文件hello.bat,其中包含以下代码:

I have a file hello.bat with the following code:

echo first: %1 and second: %2 > me.txt

我正在尝试使用powershell来称呼它.当我传递第一个参数时,它运行良好:

I am trying to call this using powershell. When I pass the first parameter it works well:

 start-process hello test

但是,当我尝试像这样传递第二个参数时:

However when i try to pass the second parameter like this:

 start-process hello test test2

我收到此错误:

开始过程:找不到接受参数'test2'的位置参数

Start-Process : A positional parameter cannot be found that accepts argument 'test2'

推荐答案

您可以尝试使用逗号来传递参数,如下所示:

You can just try pass the arguments using a comma like this:

start-process hello test,test2

start-process hello "test test2"

如果您想了解更多信息,可以阅读文档

If you want to know more you can read the documentation here.

这篇关于在批处理文件中传递第二个参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆