Batch file 将参数传递到windows命令脚本

Batch file 将参数传递到windows命令脚本,batch-file,Batch File,我需要将参数从wsf文件传递到bat文件,再传递到windows命令脚本。 在wsf文件中,我有: Shell.Run("Something.bat ",&varparam,1,true) 在某物中。蝙蝠: sftp.exe testcommand.cmd %1 echo open user@address testcommand.bat echo put %1 >> testcommand.bat sftp.exe -b testcommand.bat 在testc

我需要将参数从wsf文件传递到bat文件,再传递到windows命令脚本。 在wsf文件中,我有:

Shell.Run("Something.bat ",&varparam,1,true)
在某物中。蝙蝠:

sftp.exe testcommand.cmd %1
echo open user@address testcommand.bat
echo put %1 >> testcommand.bat

sftp.exe -b testcommand.bat
在testcommand.cmd中:

open user@address
put %1

但是.cmd文件无法访问参数值。如何使其工作?

为了将值传递到批处理中,您可以使用
调用
试试这个:

CALL Something.bat %varparam%
我认为问题的一部分是,您试图将值传递到一个命令文件中,该文件已经是一个单独字符串的一部分

您可以通过让您的Something.bat创建您的testcommand文件来实现这一点。 蝙蝠:

sftp.exe testcommand.cmd %1
echo open user@address testcommand.bat
echo put %1 >> testcommand.bat

sftp.exe -b testcommand.bat
它并不完美,但我很确定

sftp.exe testcommand.cmd %variable%

这是您的问题。

为了将值传递到批处理中,您可以使用
调用
试试这个:

CALL Something.bat %varparam%
我认为问题的一部分是,您试图将值传递到一个命令文件中,该文件已经是一个单独字符串的一部分

您可以通过让您的Something.bat创建您的testcommand文件来实现这一点。 蝙蝠:

sftp.exe testcommand.cmd %1
echo open user@address testcommand.bat
echo put %1 >> testcommand.bat

sftp.exe -b testcommand.bat
它并不完美,但我很确定

sftp.exe testcommand.cmd %variable%
这是你的问题