Old 15th November 2008, 20:05   #1
ghennessey
Junior Member
 
Join Date: Nov 2008
Posts: 5
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 is offline   Reply With Quote
Old 15th November 2008, 20:24   #2
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
If you remove it, changes will only take effect after reboot.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 15th November 2008, 20:39   #3
ghennessey
Junior Member
 
Join Date: Nov 2008
Posts: 5
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:

http://msdn.microsoft.com/en-us/library/ms725499.aspx

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.
ghennessey is offline   Reply With Quote
Old 15th November 2008, 20:55   #4
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
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.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 15th November 2008, 21:12   #5
ghennessey
Junior Member
 
Join Date: Nov 2008
Posts: 5
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.
ghennessey is offline   Reply With Quote
Old 15th November 2008, 21:15   #6
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
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.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 15th November 2008, 21:37   #7
ghennessey
Junior Member
 
Join Date: Nov 2008
Posts: 5
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.
ghennessey is offline   Reply With Quote
Old 15th November 2008, 22:06   #8
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
/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.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 15th November 2008, 22:37   #9
ghennessey
Junior Member
 
Join Date: Nov 2008
Posts: 5
Good to know! Thanks for all your help today, it's been invaluable.

Geoff.
ghennessey is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump