Jump to content

Recommended Posts

Posted

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

Posted

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

Posted (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 Souman

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)
:whistle: Edited by jpm
Posted

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)
:whistle:
Ok so it seems it is not working but how can I set the environment variables permanently?
Posted (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 session

RegWrite ( '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 script

Edit a typo in all session

Edited by jpm
Posted

RegWrite ( 'HKEY_CURRENT_USER\Environment', 'UserType', 'REG_SZ', $UserType )

or for all session

RegWrite ( '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 script

Thanks I will try if this works!

Posted

UDF at bottom of page to add environmental variable in registry.

http://www.autoitscript.com/forum/index.ph...ental++variable

EnvGet 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. :whistle:

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...