Exit from Inno Setup installation from [Code]

To prevent the installer from running, when prerequisites test fails, just return False from the InitializeSetup. This will exit the installer even before the wizard shows. function InitializeSetup(): Boolean; begin Result := True; if not PrerequisitesTest then begin SuppressibleMsgBox(‘Prerequisites test failed’, mbError, MB_OK, IDOK); Result := False; end; end; If you need to test prerequisites … Read more

Long descriptions on Inno Setup components

This solution uses only Inno Setup proper (not the obsolete 3rd party build of the Inno Setup of suspicious origin). The solution is partially based on my answer to Inno Setup: OnHover event. Adjust the HoverComponentChanged procedure to your needs. [Code] var LastMouse: TPoint; CompLabel: TLabel; function GetCursorPos(var lpPoint: TPoint): BOOL; external ‘[email protected] stdcall’; function … Read more

Inno Setup: Install file from Internet

Inno Download Plugin by Mitrich Software. It’s an InnoSetup script and DLL, which allows you to download files as part of your installation. It supports FTP, HTTP and HTTPS. It’s kind of a drop-in replacement for InnoTools Downloader. Only few changes required. It brings a decent download display and HTTPS and Mirror(s) support. Example: #include … Read more

Inno Setup Placing image/control on custom page

That’s what TWizardPage.Surface of type TNewNotebookPage is for. with BtnImage do begin Parent := CustomPage.Surface; { … } end; Related questions: TInputDirWizardPage with Radio Buttons (Similar question about radio buttons with more code) Add additional controls to standard Inno Setup pages? Also, never use absolute coordinates and sizes. Your layout will break, when the wizard … Read more

How to get an output of an Exec’ed program in Inno Setup?

Yes, use redirection of the standard output to a file: [Code] function NextButtonClick(CurPage: Integer): Boolean; var TmpFileName, ExecStdout: string; ResultCode: integer; begin if CurPage = wpWelcome then begin TmpFileName := ExpandConstant(‘{tmp}’) + ‘\ipconfig_results.txt’; Exec(‘cmd.exe’, ‘/C ipconfig /ALL > “‘ + TmpFileName + ‘”‘, ”, SW_HIDE, ewWaitUntilTerminated, ResultCode); if LoadStringFromFile(TmpFileName, ExecStdout) then begin MsgBox(ExecStdout, mbInformation, MB_OK); … Read more

How to set ‘Run as administrator’ on a file using Inno Setup

You can add a Registry entry in [Registry] Section that will set run as Administrator as a default action for running this app. Example: Root: “HKLM”; Subkey: “SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers”; \ ValueType: String; ValueName: “{app}\tomcat7w.exe”; ValueData: “RUNASADMIN”; \ Flags: uninsdeletekeyifempty uninsdeletevalue; MinVersion: 0,6.1

Inno Setup: copy folder, subfolders and files recursively in Code section

To recursively copy a directory programmatically use: procedure DirectoryCopy(SourcePath, DestPath: string); var FindRec: TFindRec; SourceFilePath: string; DestFilePath: string; begin if FindFirst(SourcePath + ‘\*’, FindRec) then begin try repeat if (FindRec.Name <> ‘.’) and (FindRec.Name <> ‘..’) then begin SourceFilePath := SourcePath + ‘\’ + FindRec.Name; DestFilePath := DestPath + ‘\’ + FindRec.Name; if FindRec.Attributes and … Read more

Make Inno Setup installer request privileges elevation only when needed

Inno Setup 6 has a built-in support for non-administrative install mode. Basically, you can simply set PrivilegesRequiredOverridesAllowed: [Setup] PrivilegesRequiredOverridesAllowed=commandline dialog Additionally, you will likely want to use the auto* variants of the constants. Notably the {autopf} for the DefaultDirName. [Setup] DefaultDirName={pf}\My Program The following is my (now obsolete) solution for Inno Setup 5, based on … Read more