francoiste Posted May 28, 2015 Posted May 28, 2015 (edited) i'm using "test.bat" to set an environment variable and then invoke the compiled script:@echo off SETLOCAL set MyCustomVar=HelloWorld start "title" /b /wait "%~dp0\MyCompiledScript.exe" -test1 echo DONE pausethe script source:#pragma compile(x64, false) #pragma compile(ExecLevel, highestavailable) Local $myVar = "MyCustomVar" Local $myValue = EnvGet($myVar) MsgBox(0, "TEST", "environment variable " & $myVar & " has value: " & $myValue) however, the variable is not visible to the autoit script.any ideas?--EDIT:i noticed this is due to the UAC execution level set as "highestavailable" (when the current user is member of the local admin group).script source (above) edited accordingly.this raises even more questions ... Edited May 29, 2015 by francoiste
AutoBert Posted May 28, 2015 Posted May 28, 2015 (edited) Look for 'Command Line Parameters' in the AutoIt-Help, i think this is what you are searching fore. Edited May 28, 2015 by AutoBert
Bert Posted May 28, 2015 Posted May 28, 2015 you could simply use AutoIt to do the entire thing and ditch the batch script. Just convert the batch script to autoit script. The Vollatran project My blog: http://www.vollysinterestingshit.com/
SadBunny Posted May 28, 2015 Posted May 28, 2015 First I thought maybe something went wrong because you set the envvar in one shell, then use start to spawn a second shell to which maybe the envvar was not visible, but then I thought let's just try it first... Works fine for me on my Windows 8.1!But yeah I agree with Bert. (Though AutoBert has a point as well ) Roses are FF0000, violets are 0000FF... All my base are belong to you.
francoiste Posted May 28, 2015 Author Posted May 28, 2015 (edited) <empty> Edited May 28, 2015 by francoiste moved to the bottom
argumentum Posted May 28, 2015 Posted May 28, 2015 works just fine.@echo off SETLOCAL set MyCustomVar=HelloWorld MyCompiledScript.exe -test1 set MyCustomVar="Buy World" MyCompiledScript.exe echo DONE pause Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
francoiste Posted May 28, 2015 Author Posted May 28, 2015 thanks for the replies.however, i have good reasons to do it the batch way.i'm not looking for suggestions to alternate approaches, but rather advice to solve the issue with this particular approach.please note the update done to the initial posting. it seems to be specific to execution level "highestavailable".
SadBunny Posted May 28, 2015 Posted May 28, 2015 (edited) Yes, that makes sense. The batchfile runs in a walled-off process space as you don't start it elevated ("as administrator"), and by requesting UAC elevation in your script, the script runs in another process space and has no access to temporary environment settings in the former one.Start your batchfile "as administrator" too, and it should work. (At least, it does for me.) Or set the environment variable as system variable (from command prompt: setx /M), note however that that still requires elevation./edit: if your chosen approach is almost certainly a "suboptimal" one, you're bound to get some suggestions for better ones. Live with it Edited May 28, 2015 by SadBunny Roses are FF0000, violets are 0000FF... All my base are belong to you.
francoiste Posted June 9, 2015 Author Posted June 9, 2015 i still don't fully understand why the environment variables are not being inherited during UAC elevation (for the current user).anyways, i'm now using the workaround to use a boot-strapper (*.exe) that does nothing but:carrying the ExecLevel "highestavailable"invoke the batch script (that in turn will invoke the compiled "MyCompiledScript.exe")"RunMyTest.au3":#pragma compile(x64, false) #pragma compile(ExecLevel, highestavailable) If Not @Compiled Then MsgBox(0, "ERROR", "This must be run from compiled *.exe") Exit EndIf ShellExecute(".\test.bat")
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