我正在尝试使用Access VBA函数调用VBScript以32位启动。我尝试了几种不同的Shell版本,但似乎没有任何效果,这是我最近的尝试:
Function callVS()
Dim wsh As Object
Set wsh = CreateObject("Wscript.Shell")
Dim errorCode As Integer
errorCode = wsh.Run("C:\Windows\syswow64\cscript.exe '\\hct431vntgta901\test scripts\machine queries\queryTest.vbs'", 1, True)
If errorCode <> 0 Then
MsgBox "Error was recieved"
End If
End Function
每次我尝试运行脚本时都会收到错误,我看不出错误是什么,它只是无法运行脚本。
我试过,如果我在CMD中运行以下命令,它运行脚本就好了:
C:\Windows\syswow64\cscript.exe "\\hct431vntgta901\test scripts\machine queries\queryTest.vbs"
答案 0 :(得分:1)
wsh.Run("C:\Windows\syswow64\cscript.exe ""\\hct431v ... es\queryTest.vbs""", 1, True)
^ use escaped double quotes ^
由于您在命令行中使用过双引号并且它们有效,请保留它们。但是要在字符串中放置双引号,您需要转义它们。