@@ -1,178 +0,0 @@
1−// ----------------------------------------------------------------------------
3−// Inno Setup Ver: 5.2.1
4−// Script Version: 1.3.1
5−// Author: Jared Breland <jbreland@legroom.net>
6−// Homepage: http://www.legroom.net/software
8−// Modified 10/18/2008 by John MacFarlane to set path in HKCU instead of HKLM if
9−// user does not have admin privileges. Also correctly handle the case where
13−// Enable modification of system path directly from Inno Setup installers
16−// Copy modpath.iss to the same directory as your setup script
18−// Add this statement to your [Setup] section
19−// ChangesEnvironment=yes
21−// Add this statement to your [Tasks] section
22−// You can change the Description or Flags, but the Name must be modifypath
23−// Name: modifypath; Description: &Add application directory to your system path; Flags: unchecked
25−// Add the following to the end of your [Code] section
26−// setArrayLength must specify the total number of dirs to be added
27−// Dir[0] contains first directory, Dir[1] contains second, etc.
28−// function ModPathDir(): TArrayOfString;
30−// Dir: TArrayOfString;
32−// setArrayLength(Dir, 1)
33−// Dir[0] := ExpandConstant('{app}');
36−// #include "modpath.iss"
37−// ----------------------------------------------------------------------------
43− pathArr: TArrayOfString;
45− aExecArr: TArrayOfString;
47− pathdir: TArrayOfString;
52− // Get array of new directories and act on each individually
53− pathdir := ModPathDir();
54− for d := 0 to GetArrayLength(pathdir)-1 do begin
57− if UsingWinNT() = true then begin
59− // Select HKLM or HKCU depending on whether user has admin privileges
60− if (IsAdminLoggedOn or IsPowerUserLoggedOn) then begin
61− reg := HKEY_LOCAL_MACHINE;
62− regkey := 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment';
64− reg := HKEY_CURRENT_USER;
65− regkey := 'Environment';
68− // Get current path, split into an array
69− RegQueryStringValue(reg, regkey, 'Path', oldpath);
70− oldpath := oldpath + ';';
72− while (Pos(';', oldpath) > 0) do begin
73− SetArrayLength(pathArr, i+1);
74− pathArr[i] := Copy(oldpath, 0, Pos(';', oldpath)-1);
75− oldpath := Copy(oldpath, Pos(';', oldpath)+1, Length(oldpath));
78− // Check if current directory matches app dir
79− if pathdir[d] = pathArr[i-1] then begin
80− // if uninstalling, remove dir from path
81− if IsUninstaller() = true then begin
83− // if installing, abort because dir was already in path
89− // Add current directory to new path
91− newpath := pathArr[i-1];
93− newpath := newpath + ';' + pathArr[i-1];
97− // Append app dir to path if not already included
98− if IsUninstaller() = false then begin
99− if newpath = '' then begin
100− newpath := pathdir[d];
102− newpath := newpath + ';' + pathdir[d];
107− RegWriteStringValue(reg, regkey, 'Path', newpath);
109− // Modify Win9x path
112− // Convert to shortened dirname
113− pathdir[d] := GetShortName(pathdir[d]);
115− // If autoexec.bat exists, check if app dir already exists in path
116− aExecFile := 'C:\AUTOEXEC.BAT';
117− if FileExists(aExecFile) then begin
118− LoadStringsFromFile(aExecFile, aExecArr);
119− for i := 0 to GetArrayLength(aExecArr)-1 do begin
120− if IsUninstaller() = false then begin
121− // If app dir already exists while installing, abort add
122− if (Pos(pathdir[d], aExecArr[i]) > 0) then
125− // If app dir exists and = what we originally set, then delete at uninstall
126− if aExecArr[i] = 'SET PATH=%PATH%;' + pathdir[d] then
132− // If app dir not found, or autoexec.bat didn't exist, then (create and) append to current path
133− if IsUninstaller() = false then begin
134− SaveStringToFile(aExecFile, #13#10 + 'SET PATH=%PATH%;' + pathdir[d], True);
136− // If uninstalling, write the full autoexec out
138− SaveStringsToFile(aExecFile, aExecArr, False);
142− // Write file to flag modifypath was selected
143− // Workaround since IsTaskSelected() cannot be called at uninstall and AppName and AppId cannot be "read" in Code section
144− if IsUninstaller() = false then
145− SaveStringToFile(ExpandConstant('{app}') + '\uninsTasks.txt', WizardSelectedTasks(False), False);
149−procedure CurStepChanged(CurStep: TSetupStep);
151− if CurStep = ssPostInstall then
152− if IsTaskSelected('modifypath') then
156−procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
159− selectedTasks: String;
161− appdir := ExpandConstant('{app}')
162− if CurUninstallStep = usUninstall then begin
163− if LoadStringFromFile(appdir + '\uninsTasks.txt', selectedTasks) then
164− if Pos('modifypath', selectedTasks) > 0 then
166− DeleteFile(appdir + '\uninsTasks.txt')
170−function NeedRestart(): Boolean;
172− if IsTaskSelected('modifypath') and not UsingWinNT() then begin