Jump to content
Sign in to follow this  
zenmaster

How Can I "Reset" My Variables to "Windows" Variables.

Recommended Posts

zenmaster

Imagine if I use an "AutoIt" application as a type of "Menu Program" that launched programs on demand.

Any Process Spawned would Inherit the Environment Space of the "AutoIt" app at the time it was launched.

Since the program could be in memory for quite a while,

there could become a great disparity between the Windows Environment Space when the program was initially launched and the time a process is spawned from the menu program.

What I would Like to do is do a "Resynch" so that my the environment space in my AutoIt app freshes all User and System Environment Variables.

I can use "ENVGET" to do this for "Specific Variables", but it would not be possible to know what future variables could have been created in the mean time.

Furthermore, There is an "EnvGet" and "EnvSet" but not an "EnvDelete" to remove an environment variable that may have been removed from the parent process.

Now, I could scan the the "HKCU\Environment" and "HKLM\System\CurrentControlSet\Control\Session Manager\Environment" and then just do and "EnvSet" for each entry. However, I could still be stuck with variables that had been "removed".

So I was hoping for a Nice "Elegent" way to get the Synch running so that any Process Launched by the AutoIT menu program was virtually guarenteed to inherit the same variables as if the app had been launched via a normal shortcut.

Share this post


Link to post
Share on other sites
Richard Robertson

Environment variables are not designed to be changed often, and also are not designed to be shared between program trees. What purpose do you need to keep updated?

Share this post


Link to post
Share on other sites
zenmaster

Environment variables are not designed to be changed often, and also are not designed to be shared between program trees. What purpose do you need to keep updated?

As stated above, Any Process Launced by AutoIt would need to share the matching OS Environment Space that you would return with an "ENVGET".

Since AutoIt could be in memory all day or for days if the PC is not rebooted, I need to Synch the Environments prior to Spawning a Process.

Share this post


Link to post
Share on other sites
Richard Robertson

You didn't explain why you would need to update them. What environment variable would change that often, considering that changes to global environment variables require a reboot?

Share this post


Link to post
Share on other sites
DavidKarner

ZenMaster,

There is no "EnvDelete" because you still use EnvSet to perform this action.

EnvSet("FOO","BAR") ; Set FOO = BAR

EnvSet("FOO") ; Deletes FOO from environment.

From the AutoIt help file...

EnvSet ( "envvariable" [, "value"] )

envvariable - Name of the environment variable to set.

value - [optional] Value to set the environment variable to. If a value is not used the environment variable will be deleted.

Imagine if I use an "AutoIt" application as a type of "Menu Program" that launched programs on demand.

Any Process Spawned would Inherit the Environment Space of the "AutoIt" app at the time it was launched.

Since the program could be in memory for quite a while,

there could become a great disparity between the Windows Environment Space when the program was initially launched and the time a process is spawned from the menu program.

What I would Like to do is do a "Resynch" so that my the environment space in my AutoIt app freshes all User and System Environment Variables.

I can use "ENVGET" to do this for "Specific Variables", but it would not be possible to know what future variables could have been created in the mean time.

Furthermore, There is an "EnvGet" and "EnvSet" but not an "EnvDelete" to remove an environment variable that may have been removed from the parent process.

Now, I could scan the the "HKCU\Environment" and "HKLM\System\CurrentControlSet\Control\Session Manager\Environment" and then just do and "EnvSet" for each entry. However, I could still be stuck with variables that had been "removed".

So I was hoping for a Nice "Elegent" way to get the Synch running so that any Process Launched by the AutoIT menu program was virtually guarenteed to inherit the same variables as if the app had been launched via a normal shortcut.

Share this post


Link to post
Share on other sites
joseLB

Hi Richard

I would like to go a step further on the issue of system variables, or even another solution, as you stated that env var are not to be used so frequently.

What I'm doing:

- an au3 compiled program. Not necessarly a windows service, but a program that will be started at boot time, at startup folder.

- this program shoud receive "commands" and give "answers" to other programs running at that PC.

- there is no relationship (tree, started by, etc.) betwen this program and the others that send/receive commands/answers to it. The other progs. will be even writen in something that not au3 (VB, delphi, etc.).

Initialy I devised to do this thru system vars, but the first problem is that env Vars will only be accessible to programs that AutoIt spawns , as per help, and as you can see they are not in the same tree, or whatever.

Second problem is your statement, and messages would be very frequent in both directions.

Could you suggest a mechanism for that? Read / write files is not an option, as the trafic is composed of small messages, but lots of them (maybe 10-100 ms betwen them...)

Thanks

Jose

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
Sign in to follow this  

×

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.