Sign in to follow this  
Followers 0
DirtyMonkeyXXX

Updating the Path variable for the current app

4 posts in this topic

Here's the background:

A coworker and I built a set of installers for our workstations here, included in those is a change to the PATH environmental variable that is required to run the second part of the installation.

Here's what I've tried:

I set the update to the path variable via a RegWrite to HKLM as well as HKCU. I've run EnvUpdate as well as tried using DllCall with the SendMessageTimeout/SendMessage command. The variable updates fine. If I go to a command prompt right after, it shows up just fine in %PATH%, as well as showing up OK in the Environmental Variable options in Windows. So setting it is not the problem.

Here's the problem:

The AutoIt script that is running doesn't see the PATH change. So anything it spawns doesn't see the change either. I've tried a sleeper program that sleeps for a few seconds, then calls the second part of the installation, but "sleeper" gets passed the unupdated PATH variable, and thus passes it on to the second part. The second part of the installation MUST see the PATH change, or it will crash.

If I rerun the application once the PATH has been updated, it works flawlessly, and that's one option we've considered. But we don't really want to have to make the user run the app twice just to use it. Once should be enough.

I checked the forums here and saw a reference to the window not listening for WM_SETTINGCHANGE update messages and thus, never seeing the update.

Could there be a way to make the app listen for changes?

Is there some way to flush the apps internal settings and make it regrab the new, updated ones?

Other suggestions?

Any help is greatly appreciated, and if you need to see any code, let me know and I'll post it up.

Thanks,

Share this post


Link to post
Share on other sites



On numerous occasions I have had autoit scripts shell out to themselves then exit. The user will only see the GUI reload and any info the needs preserved can be passed as command line arguements.

Share this post


Link to post
Share on other sites

On numerous occasions I have had autoit scripts shell out to themselves then exit. The user will only see the GUI reload and any info the needs preserved can be passed as command line arguements.

Gave that a shot, still doesn't recognize the updated PATH data. I had the program call itself and then exit and the path didn't change (plus I kind of got stuck in an infinite run loop, oops).

Would this work with (much as I hate to use one) a batch file that I can run hidden?

Thanks

Share this post


Link to post
Share on other sites

try to envset() the path... spawned processes may inherit it...

try this and echo %path% in the dos window...

EnvSet("path",EnvGet("path") & ";test")

RunWait("cmd")

Lar.

Ahh, this I had not tried. I knew the EnvSet only set the environment for the current app, but I though that modifying the registry should have done it as well when I called EnvUpdate.

This worked like a charm.

The way I have it running is our installers modify the registry as they used to. Then a wrapper that runs the individual installers in a specific order simply uses EnvSet with the Environment registry key and everything syncs up.

Thanks a boatload for the help!

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  
Followers 0