Re: Force System Variable Reload w/o reboot

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Andrew M (andrewmaxin_at_hotmail.com)
Date: 09/10/04


Date: Fri, 10 Sep 2004 11:23:14 -0600

Bob

    Thank you for your reply. I tried you code but regretably, it did not
work. I am trying to set an environment variable that is read by a legacy
VB3 application that uses the VB "Environ$" method. Although the Windows
Environment Variables Dialog respects the change, this variable does not.
what I need is an API that mimics loading the environment variables from the
registry as it does on startup. If there is another place (in memory or on
disk) that this value is being stored, that would work too.

Andrew

"Bob Butler" <tiredofit@nospam.com> wrote in message
news:O9d4wN1lEHA.644@tk2msftngp13.phx.gbl...
> "Andrew M" <andrewmaxin@hotmail.com> wrote in message
> news:10k3kqnetq75la2@corp.supernews.com
>> Hello
>>
>> I am trying to reset a custom system-level environment variable
>> for an application. I am having an issue with syncronization of the
>> changes. Is there a way to force windows (Win98 and up) to reload
>> that variable from the registry w/o having to reboot?
>
> try this
>
> Private Const HWND_BROADCAST = -1
> Private Const WM_WININICHANGE = &H1A
> Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
> (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
> ByRef lParam As Any) As Long
>
> Dim x As Long
> x = SendMessage(HWND_BROADCAST, WM_WININICHANGE, 1, ByVal 0&)
>
> not all apps recognize this so some things will not pick up the new
> environment variable setting but the explorer shell should
>



Relevant Pages

  • Re: Environment Variable Information
    ... Autoexec.bat that Windows XP will read are the lines that begin SET or PATH. ... So I got to create a Perl script which will verify the ... Windows XP machine which stores this information apart from registry. ... System environment variables are in the following Registry key: ...
    (microsoft.public.windowsxp.general)
  • Re: DTHML Editor not found. What?
    ... Help to find how to set Environment variables and get to the point where we can do that. ... First though go to C:\Program Files\Common Files\Microsoft Shared\Triedit in Windows Explorer. ... But let me try to explain how to register a ocx file again. ... Type set then hit ENTER. ...
    (microsoft.public.outlook.general)
  • Re: Environment Variable Information
    ... Don't you just love secret programs. ... Autoexec.bat that Windows XP will read are the lines that begin SET or PATH. ... Windows XP machine which stores this information apart from registry. ... System environment variables are in the following Registry key: ...
    (microsoft.public.windowsxp.general)
  • Identifying which Windows version ...
    ... I am running into problems interfacing with other products that have survived Windows Logo testing. ... The special problem here is that Logo requirements specify DIFFERENT places for files to go depending on which version of Windows they are running on, a sort of super mutual incompatibility feature that Microsoft invented! ... Past posted methods seem to either use GetVersion and pick through the numbers it returns, or use the Environ function to see which environment variables exist and which don't, which changes with the version as they keep adding new environment variables over time. ... Of course I could just go looking for the files, but then I run a risk of stumbling onto some old obsolete files that were copied in from another system, or were left over on the present system from before the system was upgraded. ...
    (microsoft.public.vb.enterprise)
  • Re: Can windows does the below easily?
    ... Are you trying to create a custom PATH to determine the search path when launching a ... I imagine it is usually best to try to stick with standard system environment variables instead of trying to create your own custom ... establish the lifetime of when the custom path is valid). ... Using this technique your script will be more portable across all Windows ...
    (microsoft.public.windows.server.general)