How to pass a command with spaces and quotes as a single parameter to CScript?

前端 未结 2 423
自闭症患者
自闭症患者 2020-12-19 13:02

I\'m using CScript to run a VBScript file, and I need to pass a command line to the script where the parameter includes both spaces and quotes. The entire command needs to

2条回答
  •  佛祖请我去吃肉
    2020-12-19 13:42

    It appears like you are trying to delineate values in your parameters. I suggest using something besides quotes and adding back the quotes. For example using tildes:

    Dim count
    For count = 0 To WScript.Arguments.Count-1
        WScript.Echo CStr(count) & " = " & replace(WScript.Arguments.Item(count),"~",chr(34))
    Next
    

    Passing:

    cscript myscript.vbs //Nologo "1 ~2 3~"
    0 = 1 "2 3"
    

提交回复
热议问题