Jump to content

Pass Variables Between Scripts

Recommended Posts


Hi guys,

     I've been toying with AutoIT for just a few days now and I've run into a bit of a brick wall.  I'm working on trying to pass a variable from script1 to script2, currently it looks something like this:

     Script1: $variable =  "Test"   

                    Run('AutoIt3.exe "scripts\script2.au3" $variable')    

     Script2:  MsgBox("0", "Test Box", $CmdLine[1])

     Everything works, except when the message box for script 2 launches it comes up with $variable instead of Test.  The variable is getting passed to the second script but it's not being evaluated before it's passed, it's sending the variable instead of the value.

     Is there a way to send the value of a variable instead of hardcoding the data to be passed between scripts?

Share this post

Link to post
Share on other sites

Don't forget the space after script file name.  Also, I would use the @AutoItExe macro as well.  

Run(@AutoItExe & ' "scripts\script2.au3" ' & $variable)




Share this post

Link to post
Share on other sites

There was the same question, not too ago. Search the forum. Anyway, one of the ways was to set your own environment variables then read them in the called script.

Share this post

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


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.