-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathx64.iss
131 lines (112 loc) · 4.22 KB
/
x64.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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "Java Version Manager"
#define MyAppVersion "0.3.0"
#define MyAppPublisher "Bic Potato"
#define MyAppURL "https://github.com/bic-potato/JavaVersionManager"
#define MyAppExeName "jvmain.exe"
[Setup]
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{8D86B7FB-6F06-4B04-8C70-3F8F74F8FD14}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={localappdata}\{#MyAppName}
;DefaultGroupName={#MyAppName}
LicenseFile=C:\Users\m1333\Documents\Programming\JavaVersionManager\LICENSE
; Uncomment the following line to run in non administrative install mode (install for current user only.)
;PrivilegesRequired=lowest
OutputDir=C:\Users\m1333\Documents\Programming\JavaVersionManager\target\release
OutputBaseFilename=JavaVersionManager_v0.3.0_x64
Compression=lzma
SolidCompression=yes
WizardStyle=modern
ChangesEnvironment=yes
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "SimplifiedChinese"; MessagesFile: "compiler:\Languages\ChineseSimplified.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "C:\Users\m1333\Documents\Programming\JavaVersionManager\target\release\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\m1333\Documents\Programming\JavaVersionManager\jvman.cmd"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\m1333\Documents\Programming\JavaVersionManager\jvman.ps1"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\m1333\Documents\Programming\JavaVersionManager\versions.toml"; DestDir: "{app}"; Flags: onlyifdoesntexist
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
;[Run]
;Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
[dirs]
Name:"{app}\java"
Name:"{app}\temp"
[UninstallDelete]
Type: filesandordirs; Name: "{app}\java"
Type: filesandordirs; Name: "{app}\temp"
[Registry]
Root: HKLM; Subkey:"SYSTEM\CurrentControlSet\Control\Session Manager\Environment";ValueType: expandsz; ValueName:"Path"; ValueData:"{app}/OpenJDK/bin;{app};{olddata}";Check: NeedsAddPath('{app}')
[Code]
const
EnvironmentKey = 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment';
function NeedsAddPath(Param: string): boolean;
var
OrigPath: string;
begin
if not RegQueryStringValue(HKEY_LOCAL_MACHINE,
EnvironmentKey,
'Path', OrigPath)
then begin
Result := True;
exit;
end;
{ look for the path with leading and trailing semicolon }
{ Pos() returns 0 if not found }
Result := Pos(';' + Param + ';', ';' + OrigPath + ';') = 0;
end;
procedure RemovePath(Path: string);
var
Paths: string;
P: Integer;
begin
if not RegQueryStringValue(HKLM, EnvironmentKey, 'Path', Paths) then
begin
Log('PATH not found');
end
else
begin
Log(Format('PATH is [%s]', [Paths]));
P := Pos(';' + Uppercase(Path) + ';', ';' + Uppercase(Paths) + ';');
if P = 0 then
begin
Log(Format('Path [%s] not found in PATH', [Path]));
end
else
begin
if P > 1 then P := P - 1;
Delete(Paths, P, Length(Path) + 1);
Log(Format('Path [%s] removed from PATH => [%s]', [Path, Paths]));
if RegWriteStringValue(HKLM, EnvironmentKey, 'Path', Paths) then
begin
Log('PATH written');
end
else
begin
Log('Error writing PATH');
end;
end;
end;
end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
if CurUninstallStep = usUninstall then
begin
RemovePath(ExpandConstant('{app}'));
RemovePath(ExpandConstant('{app}/OpenJDK/bin'));
end;
end;