2014-04-04 143 views
0

我只想从vb脚本中隐藏执行一个批处理文件。我的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 

回答

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 

你的问题是,最小的参数应该是CHR(34)之后。

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

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 
相关问题