summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2008-10-18 18:48:23 +0000
committerfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2008-10-18 18:48:23 +0000
commit1aed6a9ee48698d43ce02d4a615be25b5c4dbed6 (patch)
tree68ba0f04ef6d5bc6a29873c9d556d1dff92d9d73
parent51a58987b3d95e293b8a483ea21f199bab1fba8b (diff)
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
-rw-r--r--windows/modpath.iss29
1 files changed, 25 insertions, 4 deletions
diff --git a/windows/modpath.iss b/windows/modpath.iss
index ea3cef8e8..73ae434ac 100644
--- a/windows/modpath.iss
+++ b/windows/modpath.iss
@@ -5,6 +5,10 @@
// Author: Jared Breland <jbreland@legroom.net>
// 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:
// Enable modification of system path directly from Inno Setup installers
//
@@ -41,6 +45,8 @@ var
aExecArr: TArrayOfString;
i, d: Integer;
pathdir: TArrayOfString;
+ reg: Integer;
+ regkey: String;
begin
// Get array of new directories and act on each individually
@@ -50,8 +56,17 @@ begin
// Modify WinNT path
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
- RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment', 'Path', oldpath);
+ RegQueryStringValue(reg, regkey, 'Path', oldpath);
oldpath := oldpath + ';';
i := 0;
while (Pos(';', oldpath) > 0) do begin
@@ -80,11 +95,16 @@ begin
end;
// Append app dir to path if not already included
- if IsUninstaller() = false then
- newpath := newpath + ';' + pathdir[d];
+ if IsUninstaller() = false then begin
+ if newpath = '' then begin
+ newpath := pathdir[d];
+ end else begin
+ newpath := newpath + ';' + pathdir[d];
+ end;
+ end;
// Write new path
- RegWriteStringValue(HKEY_LOCAL_MACHINE, 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment', 'Path', newpath);
+ RegWriteStringValue(reg, regkey, 'Path', newpath);
// Modify Win9x path
end else begin
@@ -155,3 +175,4 @@ begin
Result := False;
end;
end;
+