批处理文件无法立即看到 InstallShield 脚本创建的环境变量 [英] Batch file can't immediately see environment variables created by InstallShield script
问题描述
我们使用 InstallShield 2008 进行产品安装.产品由几个组件组成.安装组件时,会执行一个批处理文件,其中包含一些特定于该组件的安装后例程.
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.
问题:安装后批处理文件使用了一些在产品安装过程中通过InstallScript设置的环境变量.但似乎批处理文件无法看到注册表(以及新创建的环境变量)中的即时更改.
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?
可能有用的信息:目标系统 - Windows XP,当前登录的用户在 Administrators 组中.
Potentially useful information: target system - Windows XP, currently logged in user is in Administrators group.
推荐答案
我在使用早期版本的 InstallShield 时遇到了同样的问题.这是我解决它的方法(快速而肮脏的代码).
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;
关键是使用SendMessage.希望对您有所帮助.
The key is to use SendMessage. Hope it helps.
这篇关于批处理文件无法立即看到 InstallShield 脚本创建的环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!