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

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;

Related

How to open a site when user click No on Uninstall Msgbox?

Is there a way to do that?
Click on 'No' button and a site will open with default browser?
Thank you!
There's no direct API to detect that the user clicked "No".
But knowing that the uninstaller:
calls InitializeUninstall;
displays the prompt;
if user clicked "No", uninstallation is aborted and DeinitializeUninstall is called;
if user clicked "Yes", uninstallation is started and as the very first thing, CurUninstallStepChanged is called for the first time (with usAppMutexCheck).
So if DeinitializeUninstall is called without CurUninstallStepChanged ever being called, you know that the user clicked "No".
[Code]
var
UninstallationStarted: Boolean;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
UninstallationStarted := True;
end;
procedure DeinitializeUninstall();
var
ErrorCode: Integer;
begin
if not UninstallationStarted then
begin
Log('User clicked No');
ShellExec('open', 'https://www.example.com/uninstallationaborted', '', '',
SW_SHOW, ewNoWait, ErrorCode);
end;
end;
There's no way of limiting the launching of the website to just the "No" button. You can use the DeinitializeUninstall procedure to perform actions when the uninstall is shutting down (which happens in both "Yes" and "No" clicks).
Here's an example of launching a website in a couple of different places:
; 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={{15B3741D-9217-4F84-971A-9F5DD837B50B}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DisableProgramGroupPage=yes
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: "{commonprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
[code]
function InitializeUninstall(): Boolean;
var
ErrCode : integer;
begin
//This will launch the website before the "Do you want to remove..." dialog
ShellExec('open', 'http://google.com/', '', '', SW_SHOW, ewNoWait, ErrCode);
result := true;
end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var
ErrCode : integer;
begin
//This will launch the website after "yes" is clicked in the "Do you want to remove..." dialog.
ShellExec('open', 'http://google.com/', '', '', SW_SHOW, ewNoWait, ErrCode);
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: Store all user's choices in an INI file

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;

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