annotate contrib/packaging/inno/modpath.iss @ 41847:0f49b56d5d74

inno: replace add_path.exe with a Pascal script While attempting to build the Inno installer, I was unable to find a copy of add_path.exe from the source site previously listed in the docs. Some quick Googling revealed that achieving this functionality in native Pascal scripts seems to be preferred these days. This commit vendors "Modify Path" (fetched from https://www.legroom.net/software/modpath) and plugs it into our Inno config file per its instructions. The existing Inno installer appears to only modify PATH for the current user (as opposed to at the system level). I've maintained this behavior with Modify Path. Although it would be trivial to change or add checkboxes to control the behavior. I'll leave this as a follow-up. Differential Revision: https://phab.mercurial-scm.org/D6060
author Gregory Szorc <gregory.szorc@gmail.com>
date Thu, 28 Feb 2019 12:54:48 -0800
parents
children 109315c41d5e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
41847
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1 // ----------------------------------------------------------------------------
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
2 //
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
3 // Inno Setup Ver: 5.4.2
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
4 // Script Version: 1.4.2
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
5 // Author: Jared Breland <jbreland@legroom.net>
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
6 // Homepage: http://www.legroom.net/software
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
7 // License: GNU Lesser General Public License (LGPL), version 3
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
8 // http://www.gnu.org/licenses/lgpl.html
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
9 //
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
10 // Script Function:
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
11 // Allow modification of environmental path directly from Inno Setup installers
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
12 //
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
13 // Instructions:
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
14 // Copy modpath.iss to the same directory as your setup script
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
15 //
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
16 // Add this statement to your [Setup] section
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
17 // ChangesEnvironment=true
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
18 //
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
19 // Add this statement to your [Tasks] section
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
20 // You can change the Description or Flags
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
21 // You can change the Name, but it must match the ModPathName setting below
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
22 // Name: modifypath; Description: &Add application directory to your environmental path; Flags: unchecked
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
23 //
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
24 // Add the following to the end of your [Code] section
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
25 // ModPathName defines the name of the task defined above
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
26 // ModPathType defines whether the 'user' or 'system' path will be modified;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
27 // this will default to user if anything other than system is set
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
28 // setArrayLength must specify the total number of dirs to be added
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
29 // Result[0] contains first directory, Result[1] contains second, etc.
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
30 // const
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
31 // ModPathName = 'modifypath';
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
32 // ModPathType = 'user';
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
33 //
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
34 // function ModPathDir(): TArrayOfString;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
35 // begin
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
36 // setArrayLength(Result, 1);
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
37 // Result[0] := ExpandConstant('{app}');
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
38 // end;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
39 // #include "modpath.iss"
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
40 // ----------------------------------------------------------------------------
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
41
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
42 procedure ModPath();
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
43 var
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
44 oldpath: String;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
45 newpath: String;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
46 updatepath: Boolean;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
47 pathArr: TArrayOfString;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
48 aExecFile: String;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
49 aExecArr: TArrayOfString;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
50 i, d: Integer;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
51 pathdir: TArrayOfString;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
52 regroot: Integer;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
53 regpath: String;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
54
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
55 begin
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
56 // Get constants from main script and adjust behavior accordingly
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
57 // ModPathType MUST be 'system' or 'user'; force 'user' if invalid
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
58 if ModPathType = 'system' then begin
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
59 regroot := HKEY_LOCAL_MACHINE;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
60 regpath := 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment';
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
61 end else begin
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
62 regroot := HKEY_CURRENT_USER;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
63 regpath := 'Environment';
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
64 end;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
65
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
66 // Get array of new directories and act on each individually
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
67 pathdir := ModPathDir();
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
68 for d := 0 to GetArrayLength(pathdir)-1 do begin
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
69 updatepath := true;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
70
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
71 // Modify WinNT path
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
72 if UsingWinNT() = true then begin
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
73
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
74 // Get current path, split into an array
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
75 RegQueryStringValue(regroot, regpath, 'Path', oldpath);
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
76 oldpath := oldpath + ';';
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
77 i := 0;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
78
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
79 while (Pos(';', oldpath) > 0) do begin
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
80 SetArrayLength(pathArr, i+1);
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
81 pathArr[i] := Copy(oldpath, 0, Pos(';', oldpath)-1);
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
82 oldpath := Copy(oldpath, Pos(';', oldpath)+1, Length(oldpath));
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
83 i := i + 1;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
84
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
85 // Check if current directory matches app dir
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
86 if pathdir[d] = pathArr[i-1] then begin
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
87 // if uninstalling, remove dir from path
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
88 if IsUninstaller() = true then begin
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
89 continue;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
90 // if installing, flag that dir already exists in path
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
91 end else begin
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
92 updatepath := false;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
93 end;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
94 end;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
95
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
96 // Add current directory to new path
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
97 if i = 1 then begin
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
98 newpath := pathArr[i-1];
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
99 end else begin
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
100 newpath := newpath + ';' + pathArr[i-1];
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
101 end;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
102 end;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
103
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
104 // Append app dir to path if not already included
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
105 if (IsUninstaller() = false) AND (updatepath = true) then
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
106 newpath := newpath + ';' + pathdir[d];
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
107
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
108 // Write new path
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
109 RegWriteStringValue(regroot, regpath, 'Path', newpath);
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
110
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
111 // Modify Win9x path
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
112 end else begin
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
113
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
114 // Convert to shortened dirname
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
115 pathdir[d] := GetShortName(pathdir[d]);
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
116
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
117 // If autoexec.bat exists, check if app dir already exists in path
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
118 aExecFile := 'C:\AUTOEXEC.BAT';
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
119 if FileExists(aExecFile) then begin
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
120 LoadStringsFromFile(aExecFile, aExecArr);
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
121 for i := 0 to GetArrayLength(aExecArr)-1 do begin
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
122 if IsUninstaller() = false then begin
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
123 // If app dir already exists while installing, skip add
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
124 if (Pos(pathdir[d], aExecArr[i]) > 0) then
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
125 updatepath := false;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
126 break;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
127 end else begin
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
128 // If app dir exists and = what we originally set, then delete at uninstall
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
129 if aExecArr[i] = 'SET PATH=%PATH%;' + pathdir[d] then
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
130 aExecArr[i] := '';
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
131 end;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
132 end;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
133 end;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
134
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
135 // If app dir not found, or autoexec.bat didn't exist, then (create and) append to current path
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
136 if (IsUninstaller() = false) AND (updatepath = true) then begin
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
137 SaveStringToFile(aExecFile, #13#10 + 'SET PATH=%PATH%;' + pathdir[d], True);
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
138
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
139 // If uninstalling, write the full autoexec out
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
140 end else begin
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
141 SaveStringsToFile(aExecFile, aExecArr, False);
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
142 end;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
143 end;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
144 end;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
145 end;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
146
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
147 // Split a string into an array using passed delimeter
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
148 procedure MPExplode(var Dest: TArrayOfString; Text: String; Separator: String);
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
149 var
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
150 i: Integer;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
151 begin
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
152 i := 0;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
153 repeat
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
154 SetArrayLength(Dest, i+1);
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
155 if Pos(Separator,Text) > 0 then begin
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
156 Dest[i] := Copy(Text, 1, Pos(Separator, Text)-1);
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
157 Text := Copy(Text, Pos(Separator,Text) + Length(Separator), Length(Text));
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
158 i := i + 1;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
159 end else begin
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
160 Dest[i] := Text;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
161 Text := '';
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
162 end;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
163 until Length(Text)=0;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
164 end;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
165
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
166
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
167 procedure CurStepChanged(CurStep: TSetupStep);
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
168 var
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
169 taskname: String;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
170 begin
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
171 taskname := ModPathName;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
172 if CurStep = ssPostInstall then
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
173 if IsTaskSelected(taskname) then
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
174 ModPath();
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
175 end;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
176
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
177 procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
178 var
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
179 aSelectedTasks: TArrayOfString;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
180 i: Integer;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
181 taskname: String;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
182 regpath: String;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
183 regstring: String;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
184 appid: String;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
185 begin
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
186 // only run during actual uninstall
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
187 if CurUninstallStep = usUninstall then begin
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
188 // get list of selected tasks saved in registry at install time
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
189 appid := '{#emit SetupSetting("AppId")}';
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
190 if appid = '' then appid := '{#emit SetupSetting("AppName")}';
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
191 regpath := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\'+appid+'_is1');
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
192 RegQueryStringValue(HKLM, regpath, 'Inno Setup: Selected Tasks', regstring);
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
193 if regstring = '' then RegQueryStringValue(HKCU, regpath, 'Inno Setup: Selected Tasks', regstring);
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
194
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
195 // check each task; if matches modpath taskname, trigger patch removal
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
196 if regstring <> '' then begin
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
197 taskname := ModPathName;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
198 MPExplode(aSelectedTasks, regstring, ',');
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
199 if GetArrayLength(aSelectedTasks) > 0 then begin
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
200 for i := 0 to GetArrayLength(aSelectedTasks)-1 do begin
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
201 if comparetext(aSelectedTasks[i], taskname) = 0 then
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
202 ModPath();
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
203 end;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
204 end;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
205 end;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
206 end;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
207 end;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
208
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
209 function NeedRestart(): Boolean;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
210 var
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
211 taskname: String;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
212 begin
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
213 taskname := ModPathName;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
214 if IsTaskSelected(taskname) and not UsingWinNT() then begin
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
215 Result := True;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
216 end else begin
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
217 Result := False;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
218 end;
0f49b56d5d74 inno: replace add_path.exe with a Pascal script
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
219 end;