将变量从vbs传递到批处理文件[重复]

时间:2021-09-08 11:44:39

This question already has an answer here:

这个问题在这里已有答案:

I am trying to pass a string that is contained in a variable named sDateFile into test.bat using the following line:

我试图使用以下行将名为sDateFile的变量中包含的字符串传递给test.bat:

WshShell.Run "test.bat sDateFile"

And to check whether test.bat has received the variable. I get test.bat to do the following:

并检查test.bat是否已收到变量。我得到test.bat来做以下事情:

echo %1

But my output is sDateFile, not the string in the variable. Am I approaching my problem incorrectly? Would there be a better way to approach it?

但我的输出是sDateFile,而不是变量中的字符串。我错误地接近了我的问题吗?有没有更好的方法来接近它?

1 个解决方案

#1


2  

You have to concat your bat file and the value of sDateFile. There is a SPACE after test.bat

您必须连接您的bat文件和sDateFile的值。 test.bat之后有一个SPACE

WshShell.Run "test.bat " + chr(34) + sDateFile + chr(34)

Run command

#1


2  

You have to concat your bat file and the value of sDateFile. There is a SPACE after test.bat

您必须连接您的bat文件和sDateFile的值。 test.bat之后有一个SPACE

WshShell.Run "test.bat " + chr(34) + sDateFile + chr(34)

Run command