uacsendmessageelevated-privilegesuipi

How to broadcast window message from elevated installer process to user windows?


There is an InstallShield installer
it writes new environment variables
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
and calls
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE,...
also it creates shortcuts in the Start menu
but right after installation they don't work because the program needs new variables.

The installer usually asks for system restart,
but in some configurations it doesn't and this problem was found accidentally.

I googled that probably the reason is in UAC and UIPI:
installer runs elevated and the message does not come to user's windows
and Start menu shortcuts also don't know about new variables
only after logoff-logon they become working

So the question:
is it possible to broadcast to all user's windows?

I was surprised, it looks strange that "broadcast" is not real broadcast
or I missed something?

BTW
it seems that Visual Studio Spy++ message monitor doesn't work if UAC is turned on


Solution

  • ...whoops, I've found solution
    just run nircmd sysrefresh environment

    -SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, pEnv, 0, 333, pRes);
    +LaunchApplication(SUPPORTDIR ^ "nircmd.exe", "sysrefresh environment", SUPPORTDIR, SW_HIDE, INFINITE, LAAW_OPTION_WAIT);
    

    so it's something wrong in InstallShield
    closed.