批处理文件中不能立即看到环境变量通过的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 的,当前登录的用户是的管理员的组
Potentially useful information: target system - Windows XP, currently logged in user is in Administrators group.
推荐答案
我不得不使用InstallShield的早期版本相同的问题。下面是我解决的方式(快速和肮脏code)。
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屋!