简体   繁体   English

将参数传递给Windows命令脚本

[英]Passing parameter to windows command script

I need to pass argument from wsf file to bat file to windows command script. 我需要将参数从wsf文件传递到bat文件,再传递给Windows命令脚本。 In wsf file I have: 在wsf文件中,我有:

Shell.Run("Something.bat ",&varparam,1,true)

In Something.bat: 在Something.bat中:

sftp.exe testcommand.cmd %1

In testcommand.cmd: 在testcommand.cmd中:

open user@address
put %1

But .cmd file does not get access to the parameter value. 但是.cmd文件无法访问该参数值。 How can I get this to work? 我该如何工作?

In order to pass values into a batch you can use call Try this: 为了将值传递到批处理中,可以使用call尝试以下操作:

CALL Something.bat %varparam%

And I think part of your problem is that you are trying to pass values into a command file that is already part of a separate string. 而且我认为您的问题的一部分是您试图将值传递到已经是单独字符串一部分的命令文件中。

You could get this to work by haveing your Something.bat create your testcommand file. 您可以让Something.bat创建testcommand文件来使其工作。 Something.bat: Something.bat:

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

sftp.exe -b testcommand.bat

It's not perfect but I'm pretty sure the syntax of 这不是完美的,但我很确定

sftp.exe testcommand.cmd %variable%

is your problem. 是你的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM