Jump to content

This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.

Environment variable not updated - SendMessage

3 replies to this topic


  • Full Members
  • 8 posts

Posted 14 September 2009 - 13:28

Hello i have a known problem:
I add a new path to the environment variable PATH. After that i start a program who needs this PATH variable, but gets still the old one.

I found many posts where the people use:


sParam      = "Environment";
pParam      = &sParam;
pResult     = &lResult;

if (SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, pParam) = 0) then

The SendMessage-Command returns SUCCESS, but i get no update. I tried now many hours in many ways, with SetRegValue, with batch-files and with setx.exe. (With and without delays)

For many people the SendMessage method works, so i must do something wrong.

OS: Windows XP SP3

Can anybody help me, please????

Edited by krakos, 14 September 2009 - 13:29.

Stefan Krueger

Stefan Krueger


  • Administrators
  • 13,269 posts

Posted 15 September 2009 - 08:33

If I recall correctly the MSI engine doesn't process that broadcast message.

Did you try ChangeDir ?


  • Full Members
  • 37 posts

Posted 22 September 2009 - 17:29

Try using SetEnvironmentVariable to change the variable for the current process.

Can you provide more information on what you're trying to do?



  • Full Members
  • 8 posts

Posted 23 September 2009 - 12:50

I solved it for me with a batch file.
Within the setup i have to start an application (exe file) wich needs an entry in the PATH Enviroment-Variable. Its the path to the SQLBase server.

My working solution is following:
I wrote a batch file with input parameters. I read the enviroment variable with InstallScript and than i set it in the batch file. After that i start in the batch file the exe file, wich has now for this session the new enviroment variable. I also set it in the registry to have the variable after the setup available, too.

Sorry for my bad english.

The batch file:

set old=%1

set path=%old:~1,-1%;%path%

%2\file.exe /filename=%3 /DBNAME=%4 /SETUP /SERVER=SERVER1 /CREATEDATABASE