2014-04-04 172 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 
相關問題