Modified modpath.iss to modify HKCU path if user lacks admin privileges.
Also fixed case where oldpath is empty (previously this led to the new path beginning with a semicolon). git-svn-id: https://pandoc.googlecode.com/svn/trunk@1464 788f1e2b-df1e-0410-8736-df70ead52e1b
This commit is contained in:
parent
51a58987b3
commit
1aed6a9ee4
1 changed files with 25 additions and 4 deletions
|
@ -5,6 +5,10 @@
|
||||||
// Author: Jared Breland <jbreland@legroom.net>
|
// Author: Jared Breland <jbreland@legroom.net>
|
||||||
// Homepage: http://www.legroom.net/software
|
// Homepage: http://www.legroom.net/software
|
||||||
//
|
//
|
||||||
|
// Modified 10/18/2008 by John MacFarlane to set path in HKCU instead of HKLM if
|
||||||
|
// user does not have admin privileges. Also correctly handle the case where
|
||||||
|
// oldpath is empty.
|
||||||
|
//
|
||||||
// Script Function:
|
// Script Function:
|
||||||
// Enable modification of system path directly from Inno Setup installers
|
// Enable modification of system path directly from Inno Setup installers
|
||||||
//
|
//
|
||||||
|
@ -41,6 +45,8 @@ var
|
||||||
aExecArr: TArrayOfString;
|
aExecArr: TArrayOfString;
|
||||||
i, d: Integer;
|
i, d: Integer;
|
||||||
pathdir: TArrayOfString;
|
pathdir: TArrayOfString;
|
||||||
|
reg: Integer;
|
||||||
|
regkey: String;
|
||||||
begin
|
begin
|
||||||
|
|
||||||
// Get array of new directories and act on each individually
|
// Get array of new directories and act on each individually
|
||||||
|
@ -50,8 +56,17 @@ begin
|
||||||
// Modify WinNT path
|
// Modify WinNT path
|
||||||
if UsingWinNT() = true then begin
|
if UsingWinNT() = true then begin
|
||||||
|
|
||||||
|
// Select HKLM or HKCU depending on whether user has admin privileges
|
||||||
|
if (IsAdminLoggedOn or IsPowerUserLoggedOn) then begin
|
||||||
|
reg := HKEY_LOCAL_MACHINE;
|
||||||
|
regkey := 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment';
|
||||||
|
end else begin
|
||||||
|
reg := HKEY_CURRENT_USER;
|
||||||
|
regkey := 'Environment';
|
||||||
|
end;
|
||||||
|
|
||||||
// Get current path, split into an array
|
// Get current path, split into an array
|
||||||
RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment', 'Path', oldpath);
|
RegQueryStringValue(reg, regkey, 'Path', oldpath);
|
||||||
oldpath := oldpath + ';';
|
oldpath := oldpath + ';';
|
||||||
i := 0;
|
i := 0;
|
||||||
while (Pos(';', oldpath) > 0) do begin
|
while (Pos(';', oldpath) > 0) do begin
|
||||||
|
@ -80,11 +95,16 @@ begin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// Append app dir to path if not already included
|
// Append app dir to path if not already included
|
||||||
if IsUninstaller() = false then
|
if IsUninstaller() = false then begin
|
||||||
newpath := newpath + ';' + pathdir[d];
|
if newpath = '' then begin
|
||||||
|
newpath := pathdir[d];
|
||||||
|
end else begin
|
||||||
|
newpath := newpath + ';' + pathdir[d];
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
// Write new path
|
// Write new path
|
||||||
RegWriteStringValue(HKEY_LOCAL_MACHINE, 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment', 'Path', newpath);
|
RegWriteStringValue(reg, regkey, 'Path', newpath);
|
||||||
|
|
||||||
// Modify Win9x path
|
// Modify Win9x path
|
||||||
end else begin
|
end else begin
|
||||||
|
@ -155,3 +175,4 @@ begin
|
||||||
Result := False;
|
Result := False;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue