Inno-setup: Store all user's choices in an INI file - inno-setup

I would like to store all the choices made by a user (or the default values, if the user did not change them) during installation in an .INI file. I know about the command-line option /LOADINF and /SAVEINF, but I would like to have a similar capability without depending on the command line. This would be used to keep settings in case of re-installation, but also to define a set of settings (that are defined by an administrator) to be used in multiple installations accross decentralized offices.
Thanks for the help

It is possible to do what you are looking for. You'll need a fair amount of code in your [code] section though. I did something similar a number of years ago but I was only reading the INI. I never wrote to the INI file. you should be able to write to it using SetIni* (SetIniString, SetIniBool, etc.) functions. You can read the INI file using GetIni* functions. Here's a quick sample I threw together that gives an idea:
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "My Program"
#define MyAppVersion "1.5"
#define MyAppPublisher "My Company, Inc."
#define MyAppURL "http://www.example.com/"
#define MyAppExeName "MyProg.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={{4CCA332F-C69B-48DF-93B4-145EB88A1BCB}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={code:GetDefaultDir}
DefaultGroupName={#MyAppName}
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "C:\util\innosetup\Examples\MyProg.exe"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, "&", "&&")}}"; Flags: nowait postinstall skipifsilent
[Code]
var
FinishedInstall : boolean;
function GetDefaultDir(def: string): string;
var
sInstallPath : string;
bRes : boolean;
begin
sInstallPath := GetIniString('Common', 'TargetDir', ExpandConstant('{pf}') + '\myApp', ExpandConstant('{src}') + '\myappsetup.INI');
Result := sInstallPath;
end;
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssPostInstall then
FinishedInstall := True;
end;
procedure DeinitializeSetup();
var
bIni : boolean;
begin
if FinishedInstall then
bIni := SetIniString('Common', 'TargetDir',ExpandConstant('{app}'), ExpandConstant('{app}') + '\myappsetup.INI');
end;

Related

Unpack SFX file using Inno Setup

I'm trying to run Inno Setup to automatically extract my SFX file without having to run extract manually. Is there any way? I leave my script below.
Is there also a way to make Inno Setup extract the SFX in the Myprogramfolder created by the installer?
I have compressed the SFX file using Winrar.
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "Program2019"
#define MyAppVersion "1.0"
#define MyAppPublisher "Myappname."
#define MyAppURL "/"
[Setup]
WizardImageFile=C:\Users\Administrator\Desktop\Cover.bmp
; NOTE: The value of AppId uniquely identifies this application.
AppID={{31D336CF-0483-4A76-00000000000000000}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
DefaultDirName={pf}\Myprogram2019
DefaultGroupName={#MyAppName}
LicenseFile=C:\Users\Administrator\Desktop\Program2019\readme.txt
OutputDir=C:\Users\Administrator\Desktop\Program2019\Myprografolder
OutputBaseFilename=setup
SetupIconFile=C:\Users\Administrator\Desktop\Program2019\Myprogram\icon.ico
Compression=none
SolidCompression=true
InternalCompressLevel=Fast
[Languages]
Name: "english"; MessagesFile: "compiler:Languages\English.isl"
Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl"
[Files]
Source: "C:\Program Files (x86)\Myprogramfolder\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "C:\Users\Administrator\Desktop\Program2019\Unpack\Evilpack.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall
Source: "C:\Users\Administrator\Desktop\Program2019\languages\spanish\*"; DestDir: "{app}\game"; Languages: spanish; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Run]
Filename: "{tmp}\Evilpack.exe"; Parameters: "{tmp}\ZipFile.ZIP -d C:\TargetDir"
[Icons]
Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\Myprogram2019"; Filename: "{app}\mypro.exe"; IconFilename: {app}\icon.ico; \
AfterInstall: SetElevationBit('{commondesktop}\Myprogram.lnk')
[Code]
{ RedesignWizardFormBegin } // Don't remove this line!
// Don't modify this section. It is generated automatically.
procedure RedesignWizardForm;
begin
{ ReservationBegin }
// This part is for you. Add your specialized code here.
{ ReservationEnd }
end;
[Messages]
BeveledLabel=Myapp
Is very easy unpack in silent way SFX, setup to silent from the menu option ADVANCED, then SFX options in winrar.
That is all!!
Finally
[Files]
Source: "C:\pathtofile\yoursfx.exe"; DestDir: "C:\Program Files\";Flags: ignoreversion
[Run]
Filename: "C:\Program Files\yoursfx.exe"; StatusMsg: "Your MSG"; Flags: runascurrentuser
[Code]
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssDone then
begin;
DeleteFile(ExpandConstant('C:\Program Files\yoursfx.exe'));
begin
// user clicked Yes
end;
end;
end;

inno setup extract exe to run before installation [duplicate]

I need to copy a file to one folder, before Inno Setup starts or before the "select directory" page. I want this file to be copied from the installer and not from an external source.
I am using this code:
function NextButtonClick(PageID: Integer): Boolean;
begin
Result := True;
if (PageId = wpWelcome) then
begin
FileCopy(
ExpandConstant('file.exe'),
ExpandConstant('{reg:HKCU\SOFTWARE\XXX,InstallPath}\file.exe'), false);
end;
end;
To extract a file from the setup archive any time you need you'll have to use ExtractTemporaryFile procedure. This procedure extracts the file from the [Files] section to a temporary directory used by the setup application, which you can find on the path specified by the {tmp} constant. Then you'll just copy such extracted file to a target directory from there by expanding the mentioned constant.
If you want to do something when the setup is being initialized, but before the wizard form is created, use the InitializeSetup event function. Note, that you can even exit the setup from that function without seeing the wizard form e.g. if the file you're going to copy is critical that much. Here's a sample code, but first take a look at the commented version of it for some details:
[Code]
function InitializeSetup: Boolean;
begin
Result := True;
ExtractTemporaryFile('File.exe');
if FileCopy(ExpandConstant('{tmp}\File.exe'),
ExpandConstant('{reg:HKCU\SOFTWARE\XXX,InstallPath}\File.exe'), False)
then
MsgBox('File copying succeeded!', mbInformation, MB_OK)
else
MsgBox('File copying failed!', mbError, MB_OK)
end;
You'll need to Extract the file, first to a temporary directory, then copy it to where you want. Something like this should work:
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "My Program"
#define MyAppVersion "1.5"
#define MyAppPublisher "My Company, Inc."
#define MyAppURL "http://www.example.com/"
#define MyAppExeName "MyProg.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={{5820E516-8DD7-4481-A016-63D3F00438C8}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "C:\Program Files (x86)\Inno Setup 5\Examples\MyProg.exe"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, "&", "&&")}}"; Flags: nowait postinstall skipifsilent
[Code]
function InitializeSetup: Boolean;
var
S: AnsiString;
begin
// Show the contents of Readme.txt (non Unicode) in a message box
log('Before Extract');
ExtractTemporaryFile('myprog.exe');
log('Before FileCopy. Dest:' + ExpandConstant('{reg:HKCU\SOFTWARE\XXX,InstallPath}\file.exe'));
log('temp: ' + ExpandConstant('{tmp}\myprog.exe'));
FileCopy(ExpandConstant('{tmp}\myprog.exe'), ExpandConstant('{reg:HKCU\SOFTWARE\XXX,InstallPath}\file.exe'), false);
log('After FileCopy');
Result := True;
end;

Inno Setup Compiler: How to auto start the default browser with given url?

I am trying to start my default browser (chrome) with a given url:
http://localhost/folder
by using the inno setup compiler for windows
after the installer finishes, i run the wamp manager
what do I have to write in the run section to achive this?
ps:
this app should install a wamp portable collection (apache web server, mysql, php, phpmyadmin)
when the installer finishes, it should start the wamp manager, wait for max 5 seconds, and then it should open de default browser with a given URL
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "My Program"
#define MyAppVersion "1.5"
#define MyAppPublisher "My Company, Inc."
#define MyAppURL "http://www.example.com/"
#define WM "Wamp Manager"
#define Exewampmanager "wampmanager.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={{0BA2F7BC-1EFD-4BF5-A06B-28E003B02760}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\cow1
DefaultGroupName=My Program1
AllowNoIcons=yes
LicenseFile=D:\New Text Document.txt
InfoBeforeFile=D:\New Text Document.txt
InfoAfterFile=D:\New Text Document.txt
OutputDir=D:\inno
OutputBaseFilename=setup2
Compression=lzma
SolidCompression=yes
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Files]
Source: "C:\wamp\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
[Run]
Filename: "{app}\{#Exewampmanager}"; Description: "{cm:LaunchProgram,{#StringChange(WM, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
after hours of research, this is what i have:
and this is not the best version, but this is what i want
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "cow1"
#define MyAppVersion "1.5"
#define MyAppPublisher "my cow, Inc."
#define MyAppURL "http://www.example.com/"
#define WM "Wamp Manager"
#define Exewampmanager "wampmanager.exe"
#define Chrome "Chrome"
#define ExeChrome "chrome.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={{0BA2F7BC-1EFD-4BF5-A06B-28E003B02760}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\cow1
DefaultGroupName=My Program1
AllowNoIcons=yes
LicenseFile=D:\New Text Document.txt
InfoBeforeFile=D:\New Text Document.txt
InfoAfterFile=D:\New Text Document.txt
OutputDir=D:\inno
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes
[code]
#IFDEF UNICODE
#DEFINE AW "W"
#ELSE
#DEFINE AW "A"
#ENDIF
const
WAIT_TIMEOUT = $00000102;
SEE_MASK_NOCLOSEPROCESS = $00000040;
type
TShellExecuteInfo = record
cbSize: DWORD;
fMask: Cardinal;
Wnd: HWND;
lpVerb: string;
lpFile: string;
lpParameters: string;
lpDirectory: string;
nShow: Integer;
hInstApp: THandle;
lpIDList: DWORD;
lpClass: string;
hkeyClass: THandle;
dwHotKey: DWORD;
hMonitor: THandle;
hProcess: THandle;
end;
function ShellExecuteEx(var lpExecInfo: TShellExecuteInfo): BOOL;
external 'ShellExecuteEx{#AW}#shell32.dll stdcall';
function WaitForSingleObject(hHandle: THandle; dwMilliseconds: DWORD): DWORD;
external 'WaitForSingleObject#kernel32.dll stdcall';
function TerminateProcess(hProcess: THandle; uExitCode: UINT): BOOL;
external 'TerminateProcess#kernel32.dll stdcall';
function NextButtonClick(CurPageID: Integer): Boolean;
var
ExecInfo: TShellExecuteInfo;
ExecInfoBrowser: TShellExecuteInfo;
begin
Result := True;
if CurPageID = wpFinished then
begin
ExecInfo.cbSize := SizeOf(ExecInfo);
ExecInfo.fMask := SEE_MASK_NOCLOSEPROCESS;
ExecInfo.Wnd := 0;
ExecInfo.lpFile := ExpandConstant('{app}') + '\{#Exewampmanager}';
ExecInfo.nShow := SW_HIDE;
if ShellExecuteEx(ExecInfo) then
begin
if WaitForSingleObject(ExecInfo.hProcess, 7000) = WAIT_TIMEOUT then
begin
ExecInfoBrowser.cbSize := SizeOf(ExecInfo);
ExecInfoBrowser.fMask := SEE_MASK_NOCLOSEPROCESS;
ExecInfoBrowser.Wnd := 0;
ExecInfoBrowser.lpFile := 'http://localhost/cow';
ExecInfoBrowser.nShow := SW_HIDE;
ShellExecuteEx(ExecInfoBrowser);
end;
end;
end;
end;
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
;[Files]
;Source: "C:\wamp\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
[Run]
;Filename: "{app}\{#Exewampmanager}"; Description: "{cm:LaunchProgram,{#StringChange(WM, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
To load an URL at the end of the installation in the user's default browser, simply do this:
[Run]
Filename: http://whatever.com/something; Description: "Visit website"; Flags: postinstall shellexec
If you want it to be unticked by default, also add the unchecked flag.

Inno Setup - How to copy a file before setup start?

I need to copy a file to one folder, before Inno Setup starts or before the "select directory" page. I want this file to be copied from the installer and not from an external source.
I am using this code:
function NextButtonClick(PageID: Integer): Boolean;
begin
Result := True;
if (PageId = wpWelcome) then
begin
FileCopy(
ExpandConstant('file.exe'),
ExpandConstant('{reg:HKCU\SOFTWARE\XXX,InstallPath}\file.exe'), false);
end;
end;
To extract a file from the setup archive any time you need you'll have to use ExtractTemporaryFile procedure. This procedure extracts the file from the [Files] section to a temporary directory used by the setup application, which you can find on the path specified by the {tmp} constant. Then you'll just copy such extracted file to a target directory from there by expanding the mentioned constant.
If you want to do something when the setup is being initialized, but before the wizard form is created, use the InitializeSetup event function. Note, that you can even exit the setup from that function without seeing the wizard form e.g. if the file you're going to copy is critical that much. Here's a sample code, but first take a look at the commented version of it for some details:
[Code]
function InitializeSetup: Boolean;
begin
Result := True;
ExtractTemporaryFile('File.exe');
if FileCopy(ExpandConstant('{tmp}\File.exe'),
ExpandConstant('{reg:HKCU\SOFTWARE\XXX,InstallPath}\File.exe'), False)
then
MsgBox('File copying succeeded!', mbInformation, MB_OK)
else
MsgBox('File copying failed!', mbError, MB_OK)
end;
You'll need to Extract the file, first to a temporary directory, then copy it to where you want. Something like this should work:
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "My Program"
#define MyAppVersion "1.5"
#define MyAppPublisher "My Company, Inc."
#define MyAppURL "http://www.example.com/"
#define MyAppExeName "MyProg.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={{5820E516-8DD7-4481-A016-63D3F00438C8}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "C:\Program Files (x86)\Inno Setup 5\Examples\MyProg.exe"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, "&", "&&")}}"; Flags: nowait postinstall skipifsilent
[Code]
function InitializeSetup: Boolean;
var
S: AnsiString;
begin
// Show the contents of Readme.txt (non Unicode) in a message box
log('Before Extract');
ExtractTemporaryFile('myprog.exe');
log('Before FileCopy. Dest:' + ExpandConstant('{reg:HKCU\SOFTWARE\XXX,InstallPath}\file.exe'));
log('temp: ' + ExpandConstant('{tmp}\myprog.exe'));
FileCopy(ExpandConstant('{tmp}\myprog.exe'), ExpandConstant('{reg:HKCU\SOFTWARE\XXX,InstallPath}\file.exe'), false);
log('After FileCopy');
Result := True;
end;

Adding a "print agreement" button to the licence page in Inno Setup

I need help for putting a button (Print Agreement) on Inno Setup form to print EULA via printer.
During installation when the User Agreement page shows up there are 3 buttons (Back, Next and Cancel). I want to add one more button Print so user can print EULA document. Is there any way to do it?
Here's a simple script I put together that displays a Print button on the license screen and then opens Notepad with the license file which can be printed.
The ShellExec can be changed to the "Print" verb (shown in code but commented out) so that it can print to the default printer automatically. That doesn't take into account systems with no printers installed though. The code is:
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "My Program"
#define MyAppVersion "1.5"
#define MyAppPublisher "My Company, Inc."
#define MyAppURL "http://www.example.com/"
#define MyAppExeName "MyProg.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={{19ECF086-08A1-4A60-891F-E4D57E1266CF}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes
LicenseFile=c:\license.txt
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "C:\util\innosetup\Examples\MyProg.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "c:\license.txt"; DestDir: "{tmp}"; Flags: dontcopy
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, "&", "&&")}}"; Flags: nowait postinstall skipifsilent
[code]
var PrintButton: TButton;
procedure PrintButtonClick(Sender: TObject);
var ResultCode :integer;
begin
log('test');
ExtractTemporaryFile('license.txt');
//if not ShellExec('Print', ExpandConstant('{tmp}\license.txt'),
// '', '', SW_SHOW, ewNoWait, ResultCode) then
if not ShellExec('', ExpandConstant('{tmp}\license.txt'),
'', '', SW_SHOW, ewNoWait, ResultCode) then
log('test');
end;
procedure InitializeWizard();
begin
PrintButton := TButton.Create(WizardForm);
PrintButton.Caption := '&Print...';
PrintButton.Left := WizardForm.InfoAfterPage.Left + 96;
PrintButton.Top := WizardForm.InfoAfterPage.Height + 88;
PrintButton.OnClick := #PrintButtonClick;
PrintButton.Parent := WizardForm.NextButton.Parent;
end;
procedure CurPageChanged(CurPage: Integer);
begin
PrintButton.Visible := CurPage = wpLicense;
end;

Resources