Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
403 views
in Technique[技术] by (71.8m points)

registry - Batch file can't immediately see environment variables created by InstallShield script

We use InstallShield 2008 for our product installation. Product consists of several components. When a component is installed, a batch-file with some post-install routines specific to this component is executed.

The problem: post-install batch files use some environment variables that are set during the installation of the product through InstallScript. But it seems that batch-files can't see immediate changes in registry (and newly created environment variables).

Is there a way to accomplish installation without a system reboot?

Potentially useful information: target system - Windows XP, currently logged in user is in Administrators group.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I had the same problem with an earlier version of InstallShield. Here's the way I solved it (quick and dirty code).

#define HWND_BROADCAST          0xffff
#define WM_SETTINGCHANGE        0x001A
function UpdateEnvironmentVariable(szKey, szValue)
  NUMBER nResult;
  STRING szEnv;
  POINTER pEnv;
begin
  nResult = RegDBSetKeyValueEx(szKey, "PATH", REGDB_STRING, szValue, -1);

  szEnv = "Environment";                    
  pEnv = &szEnv;                  
  SendMessage (HWND_BROADCAST, WM_SETTINGCHANGE, 0, pEnv );
end;

The key is to use SendMessage. Hope it helps.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...