我希望能够从一个批处理文件向另一个批处理文件传递命令行参数。
例如:
first.bat:
call test.bat "echo hello world" "echo welcome "
test.bat:
set initialcommand=%1
set maincommand=%2
%maincommand%
%initialcommand%
我希望能够从一个批处理文件向另一个批处理文件传递命令行参数。
例如:
first.bat:
call test.bat "echo hello world" "echo welcome "
test.bat:
set initialcommand=%1
set maincommand=%2
%maincommand%
%initialcommand%
这是您需要的:
first.cmd:
@echo off
set maincommand=echo hello world!
call test.cmd %maincommand%
test.cmd:
@echo off
%*
first.cmd
传递实际的命令(您的示例只传递了常量字符串"maincommand"
而不是它的值)。test.cmd
执行由每个参数组成的命令,而不仅仅是第一个参数。first.cmd
时,会得到:hello world!
正如预期的那样。