Jump to content

Homes32

Active Members
  • Posts

    56
  • Joined

  • Last visited

Community Answers

  1. Homes32's post in Env does not respond to WM_SETTINGCHANGE was marked as the answer   
    Thank you all for the replies.
    Since my script that needs to listen ENV updates from external applications and is the parent process for other applications restarting it is not an option (it's a shell loader), I ended up just listening for WM_SETTINGCHANGE myself and querying the registry directly in order to perform a EnvSet() and EnvUpate() to update the "Local process" environment and push down any Env changes to @TempDir and to child processes as well.

     
    GUIRegisterMsg($WM_SETTINGCHANGE, "WindowProc") Func WindowProc($hWnd, $iMsg, $wParam, $lParam) Switch $iMsg Case $WM_SETTINGCHANGE If $lParam <> 0 Then $ilParamStringLen = _WinAPI_StrLen($lParam) $lParamString = DllStructCreate("wchar[" & $ilParamStringLen & "]", $lParam) $sString = DllStructGetData($lParamString, 1) If $sString = "Environment" Then Local $sTmpDir = RegRead("HKLM\SYSTEM\ControlSet001\Control\Session Manager\Environment", "TMP") Local $sTempDir = RegRead("HKLM\SYSTEM\ControlSet001\Control\Session Manager\Environment", "TEMP") EnvSet("TMP", $sTmpDir) EnvSet("TEMP", $sTempDir) EnvUpdate() ConsoleWrite("Env Change: Temp=" & @TempDir) EndIf EndIf EndSwitch EndFunc  
×
×
  • Create New...