从vb脚本将参数传递给批处理文件

时间:2014-04-04 10:27:10

标签: batch-file vbscript

我只是想从vb脚本中隐秘地执行批处理文件。我的vb脚本包含以下行;但它不起作用。知道我错过了什么吗?

Dim min
Dim WshShell
min = InputBox("Enter the number of mins :")
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run chr(34) & "C:\Users\XYZ\Desktop\test.bat " & min & Chr(34), 0 
Set WshShell = Nothing

2 个答案:

答案 0 :(得分:1)

试试这个:

Dim min
Dim WshShell
min = InputBox("Enter the number of mins :")
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run """C:\temp\test.bat""" & min
Set WshShell = Nothing

你的问题是min参数应该在Chr(34)之后。

WshShell.Run chr(34) & "C:\Users\XYZ\Desktop\test.bat " & Chr(34) & min, 0

答案 1 :(得分:0)

我对我的代码做了以下修改,现在正在运行。

Dim min
Dim WshShell
min = InputBox("Enter the number of mins :")
Set WshShell = CreateObject("WScript.Shell")
strCommand = "C:\Users\Rabindra\Desktop\test.bat " & min
WshShell.Run strCommand, 0, True
Set WshShell = Nothing
相关问题