1

I'm trying to call a VBScript to launch in 32-bit from with-in an Access VBA function. I have tried several different variations of Shell, but nothing seems to work, here is my most recent try:

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

The script receives an error every time I try to run it, I cannot see what the error is, it just fails to run the script.

I have tried and if I run the following command in CMD it runs the script just fine:

C:\Windows\syswow64\cscript.exe "\\hct431vntgta901\test scripts\machine queries\queryTest.vbs"

1 Answer 1

1
wsh.Run("C:\Windows\syswow64\cscript.exe ""\\hct431v ... es\queryTest.vbs""", 1, True)
                                         ^   use escaped double quotes   ^

As you have used double quotes from command line and they work, keep them. But to place a double quote inside a string, you need to escape them.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks so much, I don't know why I didn't think of that thought the single quote would work the same.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.