Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

https://ss64.com/vb/arguments.html

<!-- : Begin batch script
@ECHO OFF
CLS

cscript //nologo "%~f0?.wsf" "PROGPATH=C:\Program Files (x86)\Microsoft Office\root\Office16\WINWORD.EXE" "FILEPATH=C:\tmp\test.docx" "DUPLEXSENDKEYS=TRUE" "PAGERANGE=3-5" "COPIES=2" //job:WORD
exit /b
PAUSE
----- Begin wsf script --->
<package>
  <job id="WORD">
    <script language="VBScript">
        Dim ObjArgs
        Set ObjArgs = wscript.arguments

        Dim objDictionary
        Set objDictionary = CreateObject("Scripting.Dictionary")
        For I = 0 to objArgs.Count-1
        objDictionary.CompareMode = vbTextCompare
        objDictionary.Add Split(objArgs(I), "=")(0), Split(objArgs(I), "=")(1)
        Next

        MsgBox objDictionary("PROGPATH")
        MsgBox objDictionary("FILEPATH")
        MsgBox objDictionary("COPIES")
        MsgBox objDictionary("DUPLEXSENDKEYS")
        MsgBox objDictionary("PAGERANGE")
        STOP
        Set objDictionary = Nothing
        Set ObjArgs = Nothing
    </script>
  </job>
</package>
        Dim ObjArgs
        Set ObjArgs = wscript.arguments
' Store the arguments in a variable:
Set objArgs = Wscript.Arguments

'Count the arguments
WScript.Echo objArgs.Count

' Display all command-line arguments
For Each strArg in objArgs
  WScript.Echo strArg
Next

' Display the first 3 command-line arguments
For I = 0 to 2
  Wscript.Echo objArgs(I)
Next

'Display just the third argument
Wscript.Echo objArgs(2)

'Or without the reference
WScript.Echo "The third argument is", WScript.Arguments(2)
  • No labels