Menu
Inno Setup Install Prerequisites For Dental School. Note: with earlier Inno Setup versions it was already possible to install different files depending on the Windows version. No, nor is such a feature planned (it would be abused). If it is your intention to keep user interaction to a minimum, use the Disable*.
Setup.iss
#define DotNetRuntimeExe 'NDP461-KB3102436-x86-x64-AllOS-ENU.exe' |
[CustomMessages] |
InstallingDotNetFramework=Installing .NET Framework. This might take a few minutes... |
DotNetFrameworkFailedToLaunch=Failed to launch .NET Framework Installer with error '%1'. Please fix the error then run this installer again. |
DotNetFrameworkFailed1602=.NET Framework installation was cancelled. This installation can continue, but be aware that this application may not run unless the .NET Framework installation is completed successfully. |
DotNetFrameworkFailed1603=A fatal error occurred while installing the .NET Framework. Please fix the error, then run the installer again. |
DotNetFrameworkFailed5100=Your computer does not meet the requirements of the .NET Framework. Please consult the documentation. |
DotNetFrameworkFailedOther=The .NET Framework installer exited with an unexpected status code '%1'. Please review any other messages shown by the installer to determine whether the installation completed successfully, and abort this installation and fix the problem if it did not. |
[Files] |
Source: '{#DotNetRuntimeExe}'; DestDir: '{tmp}'; Flags: dontcopynocompressionnoencryption |
[Code] |
var |
requiresRestart: boolean; |
// Detect .NET framework 4.6.1 is missing |
// See https://msdn.microsoft.com/en-us/library/hh925568(v=vs.110).aspx |
functionDotNetIsMissing(): Boolean; |
var |
readVal: cardinal; |
success: Boolean; |
begin |
success := RegQueryDWordValue(HKLM, 'SOFTWAREMicrosoftNET Framework SetupNDPv4Full', 'Release', readVal); |
success := success and ((readVal = 394254) or (readVal = 394271)); |
Result := not success; |
end; |
// Adapted from https://blogs.msdn.microsoft.com/davidrickard/2015/07/17/installing-net-framework-4-5-automatically-with-inno-setup/ |
functionInstallDotNet(): String; |
var |
statusText: string; |
resultCode: Integer; |
begin |
statusText := WizardForm.StatusLabel.Caption; |
WizardForm.StatusLabel.Caption := CustomMessage('InstallingDotNetFramework'); |
WizardForm.ProgressGauge.Style := npbstMarquee; |
try |
ExtractTemporaryFile('{#DotNetRuntimeExe}'); |
ifnot Exec(ExpandConstant('{tmp}{#DotNetRuntimeExe}'), '/passive /norestart /showrmui /showfinalerror', '', SW_SHOW, ewWaitUntilTerminated, resultCode) then |
begin |
Result := FmtMessage(CustomMessage('DotNetFrameworkFailedToLaunch'), [SysErrorMessage(resultCode)]); |
end |
else |
begin |
// See https://msdn.microsoft.com/en-us/library/ee942965(v=vs.110).aspx#return_codes |
case resultCode of |
0: begin |
// Successful |
end; |
1602 : begin |
MsgBox(CustomMessage('DotNetFrameworkFailed1602'), mbInformation, MB_OK); |
end; |
1603: begin |
Result := CustomMessage('DotNetFrameworkFailed1603'); |
end; |
1641: begin |
requiresRestart := True; |
end; |
3010: begin |
requiresRestart := True; |
end; |
5100: begin |
Result := CustomMessage('DotNetFrameworkFailed5100'); |
end; |
elsebegin |
MsgBox(FmtMessage(CustomMessage('DotNetFrameworkFailedOther'), [IntToStr(resultCode)]), mbError, MB_OK); |
end; |
end; |
end; |
finally |
WizardForm.StatusLabel.Caption := statusText; |
WizardForm.ProgressGauge.Style := npbstNormal; |
end; |
end; |
functionPrepareToInstall(var NeedsRestart: Boolean): String; |
begin |
// 'NeedsRestart' only has an effect if we return a non-empty string, thus aborting the installation. |
// If the installers indicate that they want a restart, this should be done at the end of installation. |
// Therefore we set the global 'restartRequired' if a restart is needed, and return this from NeedRestart() |
if DotNetIsMissing() then |
begin |
Result := InstallDotNet(); |
end; |
end; |
functionNeedRestart(): Boolean; |
begin |
Result := requiresRestart; |
end |
commented Apr 11, 2018
ok |
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment
25 Feb 2017CPOL
Create an Installer which allows to change the Forms application settings in a custom Inno Setup page
Introduction
I needed an installer which could change the settings of a Windows Forms application during install. Inno Setup allows to program custom setup pages in the built in Pascal like scripting language.
Using the Code
Prerequisites
- Inno Setup 5.5.2
- Visual Studio 2013
The source code consists of a simple C# Windows Forms application and an Inno Setup script.
The C# application has two
string
settings defined (in Project - Properties - Settings
),'
The settings are saved in the .config file.
My Form
' and 'John Doe
'.The settings are saved in the .config file.
The only thing this application does is display these settings in the Form title and a text field.
After building the C# application, the Inno Setup script can be run to build and test the installer.
Of course, it is also possible to only compile the script and execute the created installer in the Output folder later.
Of course, it is also possible to only compile the script and execute the created installer in the Output folder later.
The installer will display the usual pages, and will also display a custom page where the Form title and user name can be changed:
This custom page is based on the
After pressing the last 'Finish' button, the .config file will be updated with the new settings.
TInputQueryWizardPage
type.After pressing the last 'Finish' button, the .config file will be updated with the new settings.
When the application runs, it will display the changed settings:
Points of Interest
For other custom page types, see the Inno Setup Help topic 'Pascal Scripting: Support Functions Reference'.
You can uninstall the application from Control Panel or with the 'unins000.exe' in the install folder.
History
- Version 1.0