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.
Photo

Environment Variables


12 replies to this topic

jam

jam
  • Members
  • 19 posts

Posted 23 March 2001 - 17:45

My installation adds some environment variables during the install of my product.  But for some reason Win2K does not refresh the os so when I start one of my applications that is dependent on an environment variable the app just crashes.  If I reboot and then start the app, it's fine because obviously Win2K has set the env. vars but I thought Win2k wasn't supposed to prompt for a reboot?  Does anyone know if what I'm experienceing is an Installshield bug or a Windows Installer bug??

AndrewWalker

AndrewWalker
  • Members
  • 42 posts

Posted 23 March 2001 - 17:55

Which environment variables are you setting?

There is a way to tell Windows to refresh its environment; I can look it up if necessary but I believe it is in the documentation somewhere.


jam

jam
  • Members
  • 19 posts

Posted 23 March 2001 - 18:11

I am creating and setting my own environment variables via a script function rather than using the Environment table.  I read somewhere about using SendMessageTimeout to refresh Windows.  But I shouldn't have to resort to this method on Windows 2K because I thought W2K would refresh on its own.  If it's an InstallShield bug then I want to be able to tell InstallShield support about it and if it's a windows bug then I want to let Microsoft know about it.  The problem is I can't tell who's problem it is!  Do you know?

AndrewWalker

AndrewWalker
  • Members
  • 42 posts

Posted 26 March 2001 - 15:46

NT/2000 does not refresh itself automatically.  This isn't really a bug, simply a lack of a feature.  Windows simply needs to be notified that there is a change. Typically, this is handled with code like this:
// Defines for letting Windows know there's been an
// environment change
#define WM_SETTINGCHANGE 0x001A
#define HWND_BROADCAST 0xffff
...
// Somewhere in the code, usually just after the change
// in the environment has been made
szEnv = "Environment";
pEnv = &szEnv ;
SendMessage (HWND_BROADCAST, WM_SETTINGCHANGE, 0, pEnv );

More accurately, what this does is broadcast a message to all applications that there's been a change in the environment.

This was documented in earlier versions of IS; I don't know if it is (or isn't) in current documentation.


Richard Schuster

Richard Schuster
  • Members
  • 6 posts

Posted 27 March 2001 - 10:53

Hello, I call a CA with the mentioned code after changing the environment on NT and W2K. New processes recognize the changes but the running installation process does not. This is a very serious problem for me because I have to launch some apps during the installation process. These apps need the updated environment. My solution is a little bit tricky. The apps read the environment from the registry and set it for the runnung process.
Does somebody have a better solution for this problem?

Regards,
Richard


Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 27 March 2001 - 13:03

Why not set the AppPath registry entry for the application?

Richard Schuster

Richard Schuster
  • Members
  • 6 posts

Posted 27 March 2001 - 13:13

Because the application needs some other enviroment variables too. AppPath would solve the path problem but nut the other variables.

Richard


AndrewWalker

AndrewWalker
  • Members
  • 42 posts

Posted 27 March 2001 - 17:55

The code I gave above is supposed to update all running apps as well as news apps.  If the current install is specifically not getting the message and needs it, add another call to SendMessage, but instead of HWND_BROADCAST, pass the handle of the install.

Richard Schuster

Richard Schuster
  • Members
  • 6 posts

Posted 27 March 2001 - 18:20

Hi Andrew,
which handle do you mean. hMSI which is passed to every CA or any other?

Thanks,
Richard


AndrewWalker

AndrewWalker
  • Members
  • 42 posts

Posted 27 March 2001 - 19:39

You might try hMSI, but I was actually thinking of the return value from GetWindowHandle(HWND_INSTALL).

Richard Schuster

Richard Schuster
  • Members
  • 6 posts

Posted 28 March 2001 - 14:19

Andy,
I've tried both handles, but it didn't change anything.

Richard


kris

kris
  • Members
  • 77 posts

Posted 31 August 2001 - 02:36

Andy, (or someone)

I am trying to get this SendMessage method to work....do I just put this code you talk about into my setup.rul and have a CA call this installscript code?

kris