Bagjan Wiedus Posted August 3, 2006 Share Posted August 3, 2006 Gentlepeople, I read the following about EnvSet in the online docs: A environment variable set in this way will only be accessible to programs that AutoIt spawns (Run, RunWait). Once AutoIt closes, the variables will cease to exist. When I run EnvUpdate after an EnvSet will the variable exists after a reboot? Kind regards, Jan Souman Link to comment Share on other sites More sharing options...
BigDod Posted August 3, 2006 Share Posted August 3, 2006 I could be wrong but I think the answer is no. Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
jpm Posted August 3, 2006 Share Posted August 3, 2006 (edited) Gentlepeople, I read the following about EnvSet in the online docs: A environment variable set in this way will only be accessible to programs that AutoIt spawns (Run, RunWait). Once AutoIt closes, the variables will cease to exist. When I run EnvUpdate after an EnvSet will the variable exists after a reboot? Kind regards, Jan SoumanNothing to do with permanent setting. the EnvUpdate is to be used inside the script. I am not sure I can explain when it is usefull the following code prove it is not needed for program launch inside the script. You can verify that the variable is not permanent. I don't know if there is a slight error in the doc Opt("ExpandEnvStrings",1) Run(@ComSpec & " /k set testjpm") $result="prev=%tesjpm%" EnvSet("testjpm","Jean-Paul") $result&=" set=%testjpm%" Run(@ComSpec & " /k set testjpm") EnvUpdate() $result&=" update=%testjpm%" Run(@ComSpec & " /k set testjpm") MsgBox(0,"Results",$result) Edited August 3, 2006 by jpm Link to comment Share on other sites More sharing options...
Bagjan Wiedus Posted August 3, 2006 Author Share Posted August 3, 2006 Nothing to do with permanent setting. the EnvUpdate is to be used inside the script. I am not sure I can explain when it is usefull the following code prove it is not needed for program launch inside the script. You can verify that the variable is not permanent. I don't know if there is a slight error in the doc Opt("ExpandEnvStrings",1) Run(@ComSpec & " /k set testjpm") $result="prev=%tesjpm%" EnvSet("testjpm","Jean-Paul") $result&=" set=%testjpm%" Run(@ComSpec & " /k set testjpm") EnvUpdate() $result&=" update=%testjpm%" Run(@ComSpec & " /k set testjpm") MsgBox(0,"Results",$result) Ok so it seems it is not working but how can I set the environment variables permanently? Link to comment Share on other sites More sharing options...
jpm Posted August 3, 2006 Share Posted August 3, 2006 (edited) Ok so it seems it is not working but how can I set the environment variables permanently?RegWrite ( 'HKEY_CURRENT_USER\Environment', 'UserType', 'REG_SZ', $UserType )or for all sessionRegWrite ( 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment','UserType', 'REG_SZ', $UserType )perhaps the EnvUpdate() is need after to refresh the environment working inside the running scriptEdit a typo in all session Edited August 3, 2006 by jpm Link to comment Share on other sites More sharing options...
Bagjan Wiedus Posted August 3, 2006 Author Share Posted August 3, 2006 RegWrite ( 'HKEY_CURRENT_USER\Environment', 'UserType', 'REG_SZ', $UserType )or for all sessionRegWrite ( 'HKEYHKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment','UserType', 'REG_SZ', $UserType )perhaps the EnvUpdate() is need after to refresh the environment working inside the running scriptThanks I will try if this works! Link to comment Share on other sites More sharing options...
MHz Posted August 3, 2006 Share Posted August 3, 2006 UDF at bottom of page to add environmental variable in registry.http://www.autoitscript.com/forum/index.ph...ental++variableEnvGet and EnvSet is used during the current scripts operation. EnvUpdate has little to do with EnvGet or EnvSet operation in the script.EnvUpdate is used to refresh the environmental variables in the registry so you do not need to reboot but is only available to the following script execution, not the current script.Hmm, hope I explained that right. 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