Jump to content

Problem reading return values passed through arguments in a vbscript into AutoIt

Recommended Posts

I have a vbscript which accepts arguments from AutoIt and after some logic execution, returns value into the same argument. My problem is that i am able to send the values to the vbscript through the arguments but i am not able to read the value which is written to the argument back into AutoIt. Please help me in this regard. Here is my code.


VB Script

Sub Main(Pass1, Pass2, Pass3)

var1 = Pass1


...   This is the VBScript code which executes to determine the value of Pass1



Pass1 = some value


In the above script, a value is sent to the argument Pass1 based on which some code executes and returns the value into the Pass1 again. I am able to send the value to the VBscript into the Pass1 but not able to readback the value of Pass1 after the code execution. Please help me in this regard.

Please let me know if any further information is needed.

Link to post
Share on other sites

Sounds like what your after is to create a VBScript that AutoIT will execute and pass an argument to and then get a return value from that VBScript into AutoIT. Correct me if I'm wrong just trying to clarify what you are after.



Link to post
Share on other sites

See if this small example of named arguments in VBScript gets you any further.


Option Explicit


Function Main
    Const NoArgument = 1001
    Const SomeOtherReturn = 1002
    Dim objArgs
    Set objArgs = Wscript.Arguments
    If Not objArgs.Named.Exists("ArgumentName") Then
        Main = NoArgument
        Exit Function
    End If
    'Argument found, continue script.
    'Some code to execute.
    Main = SomeOtherReturn
End Function

You can test this via command line with the following: cscript.exe vbsname.vbs /ArgumentName "value to pass"

And then check the error level that is returned with: %errorlevel%.

Link to post
Share on other sites

Hi Venix,

You got it right. That is exactly my problem. I ran the example you provided above and could see the error level as 1001 when there is no argument and 1002 when there is an argument. One thing i forgot to mention in my problem statement is that i am able to read the values in AutoIt when the vbscript returns values to the function names. The problem is only when the return value is passed through the argument instead of the function name.

Link to post
Share on other sites


I'm not sure myself to be honest, I have never assigned a value directly to an argument through VBScript. Ill try and experiment with some things but someone else might be able to give you  an answer in the meantime.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...