Skip to content
⌘ NSIS Forum Archive

EnvVarUpdate.nsh and WM_WININICHANGE timeout

9 posts

ghennessey#

EnvVarUpdate.nsh and WM_WININICHANGE timeout

The following line of code in EnvVarUpdate.nsh hangs up my installer until the timeout is hit:

SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000

If I comment this line out, everything seems to work fine, and there is no delay - I suspect this is for older operating systems. I'm working on a Windows 2003 server (the installer is for server software). I'm using NSIS 2.40.

Can this line be safely removed, or is there some fix?

I'm calling the function using:

${EnvVarUpdate} $0 "PATH" "A" "HKLM" "$INSTDIR\lib"

Thanks,

Geoff.
ghennessey#
Thanks for the quick reply.

The changes seem to take without a reboot on Server 2003 - at least when I go to 'Control Panel - System' and look at the environment variables it's there after running the installer.

WM_WININICHANGE seems to have been retired in newer Windows systems:

An application sends the WM\_WININICHANGE message to all top-level windows after making a change to the WIN.INI file. The SystemParametersInfo function sends this message after an application uses the function to change a setting in WIN.INI.


I tried sending a WM_SETTINGCHANGE instead and it didn't hang up, although I'm not sure how to verify if it's working, as the change takes regardless. I'm not sure about my syntax either:

SendMessage ${HWND_BROADCAST} ${WM_SETTINGCHANGE} 0 "STR:Environment" /TIMEOUT=5000

Is there a way in NSIS to tell which operating system is in use, and filter the message appropriately?

Thanks,

Geoff.
kichik#
The changes will appear in the control panel but if you open up a new command shell and test it you should see it won't take effect until you reboot or use the control panel to apply the change.
ghennessey#
Yes, you're right, the changes don't show up properly when I open a new command shell.

WM_SETTINGCHANGE also doesn't solve the problem after all, in that it still hangs up. It seemed to be working initially, but it's not anymore. I must have made a mistake and not saved the included file.

If I reduce the timeout to 250, the wait is much shorter, and the changes take - they show up in a new command prompt window. Do you know what the timeout is waiting for?

Thanks,

Geoff.
kichik#
The timeout is waiting for one of the programs in your system which is not responding. It might be busy or it might have some sort of a bug preventing it from responding in time.
ghennessey#
That was it exactly - there was an unresponsive IEXPLORE.EXE running in the background. After rebooting, no problem with the installer hanging up.

Is a /TIMEOUT=0 valid? Basically to say, I don't care if all the programs respond to the change, just send the message and move on? I tried it and it seems to work - a new command prompt window reflects the change.

Thanks,

Geoff.
kichik#
/TIMEOUT=0 is invalid and will act exactly as a normal SendMessage and this means completely synchronous. That means if you get a non responding program, there will be no timeout. If you don't mind for non responding programs, use a very small timeout, but not 0.