5 Replies Latest reply on Dec 16, 2016 1:03 AM by olsmir

    How to pass parameters to VBS scripts invoked from ExpeditionPCB?


      Hello All,

      Would anybody explain me how to pass parameter(s) to VBS scripts invoked from ExpeditionPCB?


      When I invoke my script without ExpeditionPCB, I can successfully pass parameters to it.

      For example, I have the following test.vbs:


      Dim objArgs

      Set objArgs = WScript.Arguments

      MsgBox objArgs(0), 0, ""

      MsgBox "The end", 0, ""


      Then I invoke it as the following line: test.vbs "111"

      As a result, I see "111" message, then "The end" message. Everything is OK.


      Then I try to invoke the above script from ExpeditionPCB.

      I open a PCB in ExpeditionPCB, then I specify the following in the keyin field: run test.vbs "111"

      As a result, I see "The end" message only, without "111" message.


      What could be wrong?



        • 1. Re: How to pass parameters to VBS scripts invoked from ExpeditionPCB?

          You can run your script from another script, like this:



                   Dim objShell        

                   Set objShell = CreateObject("WScript.Shell")

                   objShell.run chr(34) & "path_to_your_script.vbs" & chr(34) & " " & chr(34) &  "1 1 1" & chr(34)

                   set objShell = Nothing



          The next question is where do you get the parameters to feed to the script.  If you are not hard-coding them, they must come from user input, a file, or from an existing script that is collecting information.  Some more information on what you are actually trying to do and why might reveal a clear path on how to proceed. There may be some completely different way to accomplish it.

          • 2. Re: How to pass parameters to VBS scripts invoked from ExpeditionPCB?

            Let me be more specific.


            I have the following scripts: script1.vbs, script2.vbs, script3.vbs, script4.vbs.

            I invoke them separately from ExpeditionPCB (in the keyin field):


            run D:\VBScripts\script1.vbs

            run D:\VBScripts\script2.vbs

            run D:\VBScripts\script3.vbs

            run D:\VBScripts\script4.vbs


            Or I have even bound them to the separate hotkeys, with the following script:


            Set keyBindTables = Gui.Bindings("Document")

            keyBindTables.AddKeyBinding "Alt+1", "run D:\VBScripts\script1.vbs", BindCommand, BindAccelerator

            keyBindTables.AddKeyBinding "Alt+2", "run D:\VBScripts\script2.vbs", BindCommand, BindAccelerator

            keyBindTables.AddKeyBinding "Alt+3", "run D:\VBScripts\script3.vbs", BindCommand, BindAccelerator

            keyBindTables.AddKeyBinding "Alt+4", "run D:\VBScripts\script4.vbs", BindCommand, BindAccelerator


            Later I need to invoke them one after another from the batch.vbs having the following content:


            Call app.Gui.ProcessKeyin("run D:\VBScripts\script1.vbs")

            Call app.Gui.ProcessKeyin("run D:\VBScripts\script2.vbs")

            Call app.Gui.ProcessKeyin("run D:\VBScripts\script3.vbs")

            Call app.Gui.ProcessKeyin("run D:\VBScripts\script4.vbs")


            So I can successfully invoke batch.vbs to have all my scripts executed one by one. That is OK.


            Later I need to have each of my scripts separately executed with one flag (0 for example), but executed in a batch with another flag (1 for example).

            So I am going to invoke them separately from ExpeditionPCB through the hotkeys in a following manner:


            Set keyBindTables = Gui.Bindings("Document")

            FLAG = 0

            keyBindTables.AddKeyBinding "Alt+1", "run D:\VBScripts\script1.vbs " & FLAG, BindCommand, BindAccelerator

            keyBindTables.AddKeyBinding "Alt+2", "run D:\VBScripts\script2.vbs " & FLAG, BindCommand, BindAccelerator

            keyBindTables.AddKeyBinding "Alt+3", "run D:\VBScripts\script3.vbs " & FLAG, BindCommand, BindAccelerator

            keyBindTables.AddKeyBinding "Alt+4", "run D:\VBScripts\script4.vbs " & FLAG, BindCommand, BindAccelerator


            And I am going to invoke them from batch.vbs in a following manner:


            FLAG = 1

            Call app.Gui.ProcessKeyin("run D:\VBScripts\script1.vbs " & FLAG)

            Call app.Gui.ProcessKeyin("run D:\VBScripts\script2.vbs " & FLAG)

            Call app.Gui.ProcessKeyin("run D:\VBScripts\script3.vbs " & FLAG)

            Call app.Gui.ProcessKeyin("run D:\VBScripts\script4.vbs " & FLAG)


            So I know how to pass a flag to script1.vbs, script2.vbs, script3.vbs and script4.vbs, but how to detect this flag inside these scripts?



            • 3. Re: How to pass parameters to VBS scripts invoked from ExpeditionPCB?

              The shell command example I gave exactly mimics command line input, so if you use that instead of the gui.processkeyin method I believe it will work as you want.

              1 of 1 people found this helpful
              • 4. Re: How to pass parameters to VBS scripts invoked from ExpeditionPCB?

                How about using struct(Globals) object provided by Scripting Object, instead of argument passing? Refer to auto_common_useref.pdf for detail.

                Scripting Object server is available to all applications. You do not need any special calls in your script to include this server.

                Once you store the global name/key to Scripting, you can restore the value any time before closing the application(e.g. ExpeditionPCB)


                Hope this can help


                2 of 2 people found this helpful
                • 5. Re: How to pass parameters to VBS scripts invoked from ExpeditionPCB?

                  Thank you, Patrick and Nick, for your answers. Special thanks to Nick, since this is what I really need in my case: to use a Globals property for script to script communication, rather than passing parameters to the scripts.