Sign in to follow this  
Followers 0
coffeeturtle

Refresh Environment Variables

8 posts in this topic

#1 ·  Posted (edited)

How can I convert this VB code to Autoit's _SendMessage function:

SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM)"Environment")

I read that when you programmatically change an environment value and want it reflected in new programs that are launched by making the changes in the registry, none of the newly launches applications notice the change. You need to inform all the running applications that the settings have been changed. To do this you send a WM_SETTINGCHANGE message to all the running applications.

The logic is to issue a SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM)"Environment")

Alternatively, SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM)"Environment", SMTO_BLOCK, 100, &output)

I just don't know how to convert this commands to work within AutoIt.

Thank you so much for any help you can offer! :-)

Edited by coffeeturtle

Share this post


Link to post
Share on other sites



Thank you PsaltyDS. I will take a look at this right now.

I searched for some time before posting. I usually find exactly what I'm looking for in most cases. This was a case of the wrong search term on my part. I wasted time looking for _SendMessage. I should have thought more outside of the box.

Again, thanks.

Share this post


Link to post
Share on other sites

Usually get the best results searching on the most unique/specific element of what you want. For example, if you want more examples of that DllCall() to Kernel32.dll SetEnvironmentVariable, you'll get thousands of hits from DllCall or Kernel32.dll, but pretty limited hits if you search for SetEnvironmentVariable.

:blink:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Indeed! Thank you for the search tip. I was being bombarded by hits and it was a lot to sort through and many dead ends. I will need to filter better the next time.

I hope I can teach myself this new area dealing with Environment Variables and DLL calls rather quickly.

:blink:

Edited by coffeeturtle

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

PsaltyDS,

--> It appears that most of what I want to do can be handled by the built-in EnvUpdate function? would you agree? <--

Edited by coffeeturtle

Share this post


Link to post
Share on other sites

EnvUpdate() only updates the run time process of AutoIt itself. The reason for the other broadcasts is to notify other processes that there was a change (which they may or may not have been coded to do anything about).

:blink:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Ah! I see. Okay.

I see that is the case with EnvSet as well, that it only affects AutoIt, basically.

I appreciate your input.

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