Calling a VBScript using arguments

前端 未结 1 728
清酒与你
清酒与你 2021-01-29 03:30

I am trying to get a VBScript to launch another VBScript while passing an argument from the first one to the second one. I got the part of how to receive the argument on the sec

相关标签:
1条回答
  • 2021-01-29 04:03

    You need to initialize objShell with

    Set objShell = CreateObject("WScript.Shell")
    

    before you can use its .Run method.

    Also, VBScript doesn't expand variables inside strings, so you'll need to concatenate your argument to the rest of the command string:

    objShell.Run "ArgumentTest2.vbs " & arg1
    

    Note that you'll need to put tokens in double quotes if they contain spaces:

    arg1 = "My Argument"
    objShell.Run "ArgumentTest2.vbs """ & arg1 & """"
    
    0 讨论(0)
提交回复
热议问题