forked from bovender/ExcelAddinInstaller
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcode.iss
24 lines (24 loc) · 1.06 KB
/
code.iss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//http://stackoverflow.com/questions/3304463/how-do-i-modify-the-path-environment-variable-when-running-an-inno-setup-install
function NeedsAddPath(Param: string): boolean;
var
OrigPath: string;
ParamExpanded: string;
begin
//expand the setup constants like {app} from Param
ParamExpanded := ExpandConstant(Param);
//if not RegQueryStringValue(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Control\Session Manager\Environment','Path', OrigPath)
if not RegQueryStringValue(HKEY_CURRENT_USER,'Environment','Path', OrigPath)
then begin
Result := True;
exit;
end;
// look for the path with leading and trailing semicolon and with or without \ ending
// Pos() returns 0 if not found
Result := Pos(';' + UpperCase(ParamExpanded) + ';', ';' + UpperCase(OrigPath) + ';') = 0;
if Result = True then
Result := Pos(';' + UpperCase(ParamExpanded) + '\;', ';' + UpperCase(OrigPath) + ';') = 0;
// Disable if not selected
if not (IsTaskSelected('AddDirToPath') or IsTaskSelected('SharedLibs') or IsTaskSelected('ExcelAddin')) then
Result := False
end;