romulocarlos Posted February 1, 2016 Share Posted February 1, 2016 Hello. I have created a batch to suit our needs in our systems, and this batch generates some variables. The problem is: AutoIt don't recognize the variables the batch created, only Windows variables! In a example: batch: @echo off set my_var=test AutoIt $name_test = EnvGet("my_var") MsgBox($MB_SYSTEMMODAL, "", "The variable has the value of: " & @CRLF & @CRLF & $name_test) It returns nothing! But, if I change 'my_var' in AutoIt part with a Windows variable, like PATH, SYSTEMDIR, etc, it retrieves the correct variable! How I can get my variables inside autoit? Thanks! Link to comment Share on other sites More sharing options...
Developers Jos Posted February 1, 2016 Developers Share Posted February 1, 2016 How is that batchfile ran to set the Environment variable in relation to when the AutoIt3 script is ran? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
romulocarlos Posted February 1, 2016 Author Share Posted February 1, 2016 Thanks for fast reply. It runs as administrator privilegies. The AutoIt scritp runs as administrator, also. Link to comment Share on other sites More sharing options...
Developers Jos Posted February 1, 2016 Developers Share Posted February 1, 2016 (edited) Ok, but how are you running it? Because when shelling the batchfile, the environment variables created by the SET command will only live during the execution of the batch file, not in any other shelled program ...right? Jos Edited February 1, 2016 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
romulocarlos Posted February 1, 2016 Author Share Posted February 1, 2016 The batch sets the variables, the runs some programas, including the autoit script. Like this: @echo off set my_var1="test1" set my_var2="test2" start /w autoit_compiled_script.exe So, as you can see, the batch still alive when the script is called! The autoit_compiled_script.exe make use of my_var1 and my_var2! Link to comment Share on other sites More sharing options...
romulocarlos Posted February 1, 2016 Author Share Posted February 1, 2016 So, I get my variable inside AutoIt with another metodh, but I wanna learn how to read the variable directly. I used this: @echo off set my_var=test1 echo %my_var% >variable1 start /w autoit_compiled_script.exe Inside AutoIt script, I have this: FileOpen("c:\program_folder\variable1") Local $nome_logmein = FileRead("c:\program_folder\variable1") FileClose("c:\program_folder\variable1") Link to comment Share on other sites More sharing options...
Developers Jos Posted February 1, 2016 Developers Share Posted February 1, 2016 (edited) Just tested with your batchfile and this in the compiled script MsgBox(262144, 'Debug line ~' & @ScriptLineNumber, 'Selection:' & @CRLF & 'EnvGet("my_var")' & @CRLF & @CRLF & 'Return:' & @CRLF & EnvGet("my_var")) ;### Debug MSGBOX works just fine. Jos Edited February 1, 2016 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
romulocarlos Posted February 1, 2016 Author Share Posted February 1, 2016 Thanks... But you mean the batch in first post, or the last, wich uses a file to store the variable? Link to comment Share on other sites More sharing options...
Developers Jos Posted February 1, 2016 Developers Share Posted February 1, 2016 (edited) This one and not really using the created file: @echo off set my_var=test1 echo %my_var% >variable1 start /w autoit_compiled_script.exe Jos Edited February 1, 2016 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
romulocarlos Posted February 2, 2016 Author Share Posted February 2, 2016 Thanks... But don't work for me. Bellow "returns" appears a blank space... Link to comment Share on other sites More sharing options...
romulocarlos Posted February 3, 2016 Author Share Posted February 3, 2016 I'm feeling really stupid. I type some wrong code into script, so when I test script itself throught Editor, it don't get the variable. With the right code, and running the script as executable, it returns the value of my variable correctly. Thanks for the help, and sorry for my mistake. Link to comment Share on other sites More sharing options...
jdelaney Posted February 4, 2016 Share Posted February 4, 2016 (edited) edit: oops, already solved, long day. Edited February 4, 2016 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now