forked from RWS/Sdl-Community
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSDLlegit.iss
82 lines (75 loc) · 2.57 KB
/
SDLlegit.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
[Setup]
AppName=Sdl Legit!
AppPublisher=SDL Community Developers
AppPublisherURL=https://community.sdl.com/
AppVersion=1.2.0.0
DisableDirPage = yes
DisableWelcomePage = yes
AllowNoIcons = yes
DefaultDirName={pf32}\SDL\SDL Community\SDL Legit
Compression=lzma2
SolidCompression=yes
OutputDir=userdocs:Inno Setup Examples Output
PrivilegesRequired = admin
DefaultGroupName=SDL\SDL Community
[Files]
Source: "C:\Users\aghisa\AppData\Roaming\SDL\SDL Trados Studio\12\Plugins\Packages\SDLlegit.exe"; DestDir: "{app}"
Source: "C:\Users\aghisa\AppData\Roaming\SDL\SDL Trados Studio\12\Plugins\Packages\SDLlegit.exe.config"; DestDir: "{app}"
Source: "C:\Users\aghisa\AppData\Roaming\SDL\SDL Trados Studio\12\Plugins\Packages\Studio.AssemblyResolver.dll"; DestDir: "{app}"
[Icons]
Name: "{group}\SDL Legit!"; Filename: "{app}\SDLlegit.exe"; WorkingDir: "{app}"
Name: {commondesktop}\SDL Legit!; Filename: {app}\SDLlegit.exe; WorkingDir: {app};Comment: "SDL Legit!";
Name: "{group}\Uninstall SDL Legit!"; Filename: "{uninstallexe}"
[UninstallDelete]
Type: filesandordirs; Name: "c:\Program Files (x86)\SDL\SDL Trados Studio\Studio4\SDLlegit.exe"
[Code]
function GetUninstallString(): String;
var
sUnInstPath: String;
sUnInstallString: String;
appName: String;
begin
appName := 'Sdl Legit!';
sUnInstPath := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\'+appName+'_is1');
sUnInstallString := '';
if not RegQueryStringValue(HKLM, sUnInstPath, 'UninstallString', sUnInstallString) then
RegQueryStringValue(HKCU, sUnInstPath, 'UninstallString', sUnInstallString);
Result := sUnInstallString;
end;
function IsUpgrade(): Boolean;
begin
Result := (GetUninstallString() <> '');
end;
function UnInstallOldVersion(): Integer;
var
sUnInstallString: String;
iResultCode: Integer;
begin
// Return Values:
// 1 - uninstall string is empty
// 2 - error executing the UnInstallString
// 3 - successfully executed the UnInstallString
// default return value
Result := 0;
// get the uninstall string of the old app
sUnInstallString := GetUninstallString();
if sUnInstallString <> '' then begin
sUnInstallString := RemoveQuotes(sUnInstallString);
if Exec(sUnInstallString, '/SILENT /NORESTART /SUPPRESSMSGBOXES','', SW_HIDE, ewWaitUntilTerminated, iResultCode) then
Result := 3
else
Result := 2;
end else
Result := 1;
end;
/////////////////////////////////////////////////////////////////////
procedure CurStepChanged(CurStep: TSetupStep);
begin
if (CurStep=ssInstall) then
begin
if (IsUpgrade()) then
begin
UnInstallOldVersion();
end;
end;
end;