-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInstallScript.iss
124 lines (112 loc) · 3.99 KB
/
InstallScript.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
// Script generated by the Inno Setup Script Wizard.
// SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "ShowDesktop"
#define MyAppVersion "1.0.2"
#define MyAppExeName MyAppName + ".exe"
#define MyAppPublisher "NASS e.K."
#define MyAppURL "https://www.nass-ek.de"
#define ProgramFiles GetEnv("ProgramFiles")
[Setup]
AppId={{F5C7BB16-DE86-4E3D-BA40-C5766E83071A}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={autopf}\{#MyAppName}
DisableDirPage=yes
DefaultGroupName={#MyAppName}
DisableProgramGroupPage=yes
LicenseFile=D:\Dokumente\gpl_de.txt
PrivilegesRequired=lowest
OutputDir=bin/Release
OutputBaseFilename={#MyAppName}-Setup-{#MyAppVersion}
SetupIconFile={#MyAppName}.ico
UninstallDisplayIcon={app}\{#MyAppExeName},0
DisableWelcomePage=False
WizardImageFile=D:\Bilder\wz_nass-ek.bmp
WizardSmallImageFile=D:\Bilder\wz_leer_small.bmp
Compression=lzma
SolidCompression=yes
WizardStyle=modern
SignTool=Certum
[Languages]
Name: "german"; MessagesFile: "compiler:Languages\German.isl"
[CustomMessages]
PinToTaskbar=Pin to taskbar
german.PinToTaskbar=An Taskleiste anheften
HelpText=Right-click onto ShowDesktop.exe and select%nPin to Taskbar in the following window.
german.HelpText=Im folgenden Fenster Rechtsklick auf ShowDesktop.exe%nund danach 'An Taskleiste anheften' auswählen.
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{group}\Uninstall {#MyAppName}"; Filename: "{uninstallexe}"
[Files]
Source: "bin\Release\{#MyAppExeName}"; DestDir: "{app}"; DestName: "{#MyAppExeName}"; Flags: confirmoverwrite
Source: "nircmd.exe"; DestDir: "{app}"; Flags: ignoreversion
[Tasks]
Name: "PinToTaskBar"; Description: {cm:PinToTaskbar}; Flags: unchecked
[Code]
function GetUninstallString(): String;
var
sUnInstPath: String;
sUnInstallString: String;
begin
sUnInstPath := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\{#emit SetupSetting("AppId")}_is1');
sUnInstallString := '';
if not RegQueryStringValue(HKLM, sUnInstPath, 'UninstallString', sUnInstallString) then
RegQueryStringValue(HKCU, sUnInstPath, 'UninstallString', sUnInstallString);
Result := sUnInstallString;
end;
// Function to check if the current installation is an upgrade
function IsUpgrade(): Boolean;
begin
Result := (GetUninstallString() <> '');
end;
// Function to uninstall old versions of the application
function UnInstallOldVersion(): Integer;
var
sUnInstallString: String;
iResultCode: Integer;
begin
Result := 0;
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);
var
ResultCode: Integer;
begin
// Check if we are in the Install step
if (CurStep = ssInstall) then
begin
// If upgrading, uninstall the previous version
if (IsUpgrade()) then
begin
UnInstallOldVersion();
end;
end
// After installation, show the message box and run tasks
else if (CurStep = ssPostInstall) then
begin
if IsTaskSelected('PinToTaskBar') then
begin
// Show the custom HelpText message before starting the Run section tasks
MsgBox(ExpandConstant('{cm:HelpText}'), mbInformation, MB_OK);
// Check if the "PinToTaskBar" task is selected and then execute the explorer task
begin
// Open explorer window for pinning and make it topmost
Exec('explorer', ExpandConstant('{app}'), '', SW_SHOWNORMAL, ewNoWait, ResultCode);
Exec(ExpandConstant('{app}\nircmd.exe'), 'win topmost title "Explorer" 1', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
DeleteFile(ExpandConstant('{app}\nircmd.exe'));
end;
end;
end;
end;