Jump to content

Refresh Environment Variables


Recommended Posts

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
Link to comment
Share on other sites

Not much of a believer in the search function? Took about 5 seconds to search on WM_SETTINGCHANGE and find a working example.

: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
Link to comment
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.

Link to comment
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
Link to comment
Share on other sites

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
Link to comment
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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...