cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Lee1212
Level 3

Environment variable problem in install script project

Hi
I using the following code and It works fine for first time installation but when the user uninstall the product the PATH variable will damaged. can anyone give me an ide or tell me what I am doing wrong?
function OnEnd()
#define WM_WININICHANGE 0x001A
#define HWND_BROADCAST 0xffff
NUMBER nResult, nvSize, nvType, nLocation ;
STRING szKey, szEnv, svPath, szFileFound, szStr;
WPOINTER pEnv;
begin
FileRegistration("ScanX.dll");
szEnv = "";
szKey = "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment";
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
RegDBGetKeyValueEx(szKey, "Path", nvType, szEnv, nvSize);
nLocation = StrFind ( szEnv , TARGETDIR );
if (nLocation < 0) then
szEnv = szEnv + ";" + TARGETDIR;
nResult = RegDBSetKeyValueEx(szKey, "Path", REGDB_STRING, szEnv, -1);
if (nResult < 0) then
//MessageBox("Failed to Set Environment Variable", WARNING);
else
//MessageBox("Successfully Set Environment Variable", INFORMATION);
// Flush the registry to all applications.
szStr = "Environment";
pEnv = &szStr;
SendMessage (HWND_BROADCAST, WM_WININICHANGE, 0, pEnv );
endif;
// RebootDialog("", "", SYS_BOOTMACHINE);
endif;
end;

Many thanks...

I tried to move it to a feature installed event but then the PATH Environment Variable is deleted after uninstall
Labels (1)
0 Kudos
(1) Reply
rrinblue22
Level 9

Entries written to Registry key is by default logged for uninstallation by InstallScript.
you may want to call Disable(LOGGING) just before the registry key write function and then enable the same.
0 Kudos