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;
Related
I try to remove a registry key after uninstalling it in Windows, but I couldn't get it working somehow. I tried everything which was listed here: Inno Setup: Removing a problematic registry key left by another program
I checked different docs of Inno Setup:
https://jrsoftware.org/ishelp/index.php?topic=uninstalldeletesection
https://jrsoftware.org/ishelp/index.php?topic=isxfunc_regdeletekeyincludingsubkeys
https://jrsoftware.org/ishelp/index.php?topic=registrysection
https://jrsoftware.org/ishelp/index.php?topic=isxfunc_regdeletevalue
I ended up with this:
; Basic setup for a JavaFX application
#define AppName "Practicumopdracht OOP2"
#define AppVersion "1.0.0"
#define AppPublisher "Remzi Cavdar"
#define AppURL "https://twitter.com/remzicavdar"
#define AppExeName "practicumopdracht.jar"
#define AppExeDir "C:\Users\Remzi\Projects\student-1\out\artifacts\practicumopdracht_jar"
#define AppIcon "app.ico"
#define ProjectDir "C:\Users\Remzi\Projects\JavaFX-Setup"
[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={{DD7E7C3F-F4AC-4D76-8626-95019C15E111}
AppName={#AppName}
AppVersion={#AppVersion}
VersionInfoVersion=1.0.0.0
VersionInfoCopyright={#AppPublisher} - ict#remzi.info
AppVerName={#AppName}
AppPublisher={#AppPublisher}
AppPublisherURL={#AppURL}
AppSupportURL={#AppURL}
AppUpdatesURL={#AppURL}
DefaultDirName={localappdata}\Remzi Cavdar\{#AppName}
DisableProgramGroupPage=yes
PrivilegesRequired=lowest
OutputBaseFilename=Setup-practicumopdracht
Compression=lzma
SolidCompression=yes
WizardStyle=modern
UninstallDisplayName={#AppName}
UninstallDisplayIcon={app}\{#AppIcon}
MinVersion=10.0.10240
[Languages]
Name: "dutch"; MessagesFile: "compiler:Languages\Dutch.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "{#AppExeDir}\{#AppExeName}"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#ProjectDir}\{#AppIcon}"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#ProjectDir}\Input\OpenJDK19U-jre_x64_windows_hotspot_19_36.msi"; DestDir: "{tmp}"; AfterInstall: RunJavaInstaller
[Icons]
Name: "{autoprograms}\{#AppName}"; Filename: "{app}\{#AppExeName}"; IconFilename: "{app}\{#AppIcon}"
Name: "{autodesktop}\{#AppName}"; Filename: "{app}\{#AppExeName}"; IconFilename: "{app}\{#AppIcon}"; Tasks: desktopicon
[Registry]
Root: HKCU; Subkey: "Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Compatibility Assistant\Store"; ValueType: binary; ValueName: "{app}\unins000.exe"; Flags: dontcreatekey uninsdeletevalue
[Run]
Filename: "{app}\{#AppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(AppName, '&', '&&')}}"; Flags: shellexec postinstall skipifsilent
[UninstallDelete]
Type: filesandordirs; Name: "{localappdata}\Remzi Cavdar"
[Code]
procedure RunJavaInstaller;
var
ErrorCode: Integer;
begin
if not ShellExec('', 'msiexec.exe', ExpandConstant('/i "{tmp}\OpenJDK19U-jre_x64_windows_hotspot_19_36.msi" ADDLOCAL=FeatureMain,FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome,FeatureOracleJavaSoft /qb'), '', SW_SHOWNORMAL, ewWaitUntilTerminated, ErrorCode)
then
MsgBox('Java JRE installer failed to run!' + #13#10 + ' ' + SysErrorMessage(ErrorCode), mbError, MB_OK);
end;
This is what I'm trying to remove after uninstall:
I found a solution to my registry question. I needed to check for both 32-bit and 64-bit.
[Registry]
Root: HKCU; Subkey: "Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Compatibility Assistant\Store"; ValueType: binary; ValueName: "{app}\unins000.exe"; Flags: dontcreatekey uninsdeletevalue
Root: HKCU64; Subkey: "Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Compatibility Assistant\Store"; ValueType: binary; ValueName: "{app}\unins000.exe"; Flags: dontcreatekey uninsdeletevalue; Check: IsWin64
I found the answer here: Writing 32/64-bit specific registry key in Inno Setup and https://jrsoftware.org/ishelp/index.php?topic=registrysection also mention this with HKLM64 example, but I read things to fast to notice it.
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;
I have some troubles with the installer script
I want to install my app and it needs .net 4.5 to be installed on the host. Also it needs AccessRuntime2007.
I have some troubles because the Accessruntime will not install using the script.
Maybe something wrong with the sequence? who can help me?
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "JazzNotes"
#define MyAppVersion "1.0"
#define MyAppPublisher "EMDEE TECH"
#define MyAppURL "www.jazznotes.com"
#define MyAppExeName "JazzNotes.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={{2F4E8FD6-6151-45A1-A421-8CA123E312CF}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DisableProgramGroupPage=yes
LicenseFile=C:\Users\donnersm\Documents\Visual Studio 2015\Projects\MusiCAT\MusiCAT\license.txt
OutputDir=C:\Users\donnersm\Documents\Visual Studio 2015\Projects\MusiCAT\MusiCAT\inno output
OutputBaseFilename=Install Jazznotes
SetupIconFile=C:\Users\donnersm\Documents\Visual Studio 2015\Projects\MusiCAT\icons\Itzikgur-My-Seven-Music-Piano-Chello.ico
Compression=lzma
SolidCompression=yes
[Types]
Name: "full"; Description: "Full installation"
Name: "custom"; Description: "Custom installation"; Flags: iscustom
[Components]
Name: "program"; Description: "Program Files"; Types: full custom; Flags: fixed
Name: "help"; Description: "Help File"; Types: full
Name: "Net"; Description: ".NET 4.5 Framework"; Types: full
Name: "Acrobat" ; Description: "Acrobat Reader 8"; Types: full
Name: "Access" ; Description: "Access runtime files"; Types: full
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "dependencies\AccessRuntime.exe"; DestDir: {tmp}; Flags: deleteafterinstall; AfterInstall: InstallFramework2; Components: Access
Source: "dependencies\AdbeRdr11010_en_US.exe"; DestDir: {tmp}; Flags: deleteafterinstall; AfterInstall: InstallFramework3; Components: Acrobat
Source: "dependencies\dotnetfx45_full_x86_x64.exe"; DestDir: {tmp}; Flags: deleteafterinstall; AfterInstall: InstallFramework; Check: FrameworkIsNotInstalled ;Components: Net
Source: "C:\Users\donnersm\Documents\Visual Studio 2015\Projects\MusiCAT\MusiCAT\bin\x86\Release\JazzNotes.exe"; DestDir: "{app}"; Flags: ignoreversion ; Components: program
Source: "C:\Users\donnersm\Documents\Visual Studio 2015\Projects\MusiCAT\MusiCAT\bin\x86\Release\AxInterop.AcroPDFLib.dll"; DestDir: "{app}"; Flags: ignoreversion ; Components: program
Source: "C:\Users\donnersm\Documents\Visual Studio 2015\Projects\MusiCAT\MusiCAT\bin\x86\Release\AxInterop.WMPLib.dll"; DestDir: "{app}"; Flags: ignoreversion ; Components: program
Source: "C:\Users\donnersm\Documents\Visual Studio 2015\Projects\MusiCAT\MusiCAT\bin\x86\Release\Interop.AcroPDFLib.dll"; DestDir: "{app}"; Flags: ignoreversion ; Components: program
Source: "C:\Users\donnersm\Documents\Visual Studio 2015\Projects\MusiCAT\MusiCAT\bin\x86\Release\Interop.WMPLib.dll"; DestDir: "{app}"; Flags: ignoreversion ; Components: program
Source: "C:\Users\donnersm\Documents\Visual Studio 2015\Projects\MusiCAT\MusiCAT\bin\x86\Release\JazzNotes.exe.config"; DestDir: "{app}"; Flags: ignoreversion ; Components: program
Source: "C:\Users\donnersm\Documents\Visual Studio 2015\Projects\MusiCAT\MusiCAT\bin\x86\Release\NAudio.dll"; DestDir: "{app}"; Flags: ignoreversion ; Components: program
Source: "C:\Users\donnersm\Documents\Visual Studio 2015\Projects\MusiCAT\MusiCAT\bin\x86\Release\UltraID3Lib.dll"; DestDir: "{app}"; Flags: ignoreversion ; Components: program
Source: "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Microsoft.VisualBasic.Compatibility.dll"; DestDir: "{app}"; Flags: ignoreversion ; Components: program
Source: "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Core.dll"; DestDir: "{app}"; Flags: ignoreversion ; Components: program
Source: "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.DataSetExtensions.dll"; DestDir: "{app}"; Flags: ignoreversion ; Components: program
Source: "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.dll"; DestDir: "{app}"; Flags: ignoreversion ; Components: program
Source: "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Deployment.dll"; DestDir: "{app}"; Flags: ignoreversion ; Components: program
Source: "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Design.dll"; DestDir: "{app}"; Flags: ignoreversion ; Components: program
Source: "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.dll"; DestDir: "{app}"; Flags: ignoreversion ; Components: program
Source: "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Drawing.dll"; DestDir: "{app}"; Flags: ignoreversion ; Components: program
Source: "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Net.Http.dll"; DestDir: "{app}"; Flags: ignoreversion ; Components: program
Source: "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Web.dll"; DestDir: "{app}"; Flags: ignoreversion ; Components: program
Source: "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Windows.Forms.dll"; DestDir: "{app}"; Flags: ignoreversion ; Components: program
Source: "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.XML.dll"; DestDir: "{app}"; Flags: ignoreversion ; Components: program
Source: "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xml.Linq.dll"; DestDir: "{app}"; Flags: ignoreversion ; Components: program
Source: "C:\Program Files (x86)\Microsoft.NET\Primary Interop Assemblies\stdole.dll"; DestDir: "{app}"; Flags: ignoreversion ; Components: program
Source: "C:\Users\donnersm\Documents\Visual Studio 2015\Projects\MusiCAT\MusiCAT\LTYPE.TTF"; DestDir: "{app}"; Flags: ignoreversion ; Components: program
Source: "C:\Users\donnersm\Documents\Visual Studio 2015\Projects\MusiCAT\MusiCAT\LTYPEB.TTF"; DestDir: "{app}"; Flags: ignoreversion ; Components: program
Source: "C:\Users\donnersm\Documents\Visual Studio 2015\Projects\MusiCAT\MusiCAT\LTYPEBO.TTF"; DestDir: "{app}"; Flags: ignoreversion ; Components: program
Source: "C:\Users\donnersm\Documents\Visual Studio 2015\Projects\MusiCAT\MusiCAT\LTYPEO.TTF"; DestDir: "{app}"; Flags: ignoreversion ; Components: program
Source: "C:\Users\donnersm\Documents\Visual Studio 2015\Projects\MusiCAT\jingle.wav"; DestDir: "{app}"; Flags: ignoreversion ; Components: program
Source: "C:\Users\donnersm\Documents\Visual Studio 2015\Projects\MusiCAT\musica.accdb"; DestDir: "{app}"; Flags: ignoreversion ; Components: program
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Code]
function FrameworkIsNotInstalled: Boolean;
begin
Result := not RegKeyExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\.NETFramework\policy\v4.5');
end;
procedure InstallFramework;
var
StatusText: string;
ResultCode: Integer;
begin
StatusText := WizardForm.StatusLabel.Caption;
WizardForm.StatusLabel.Caption := 'Installing .NET framework...';
WizardForm.ProgressGauge.Style := npbstMarquee;
try
if not Exec(ExpandConstant('{tmp}\dotnetfx45_full_x86_x64.exe'), '/q /noreboot', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
begin
// you can interact with the user that the installation failed
MsgBox('.NET installation failed with code: ' + IntToStr(ResultCode) + '.',
mbError, MB_OK);
end;
finally
WizardForm.StatusLabel.Caption := StatusText;
WizardForm.ProgressGauge.Style := npbstNormal;
end;
end;
procedure InstallFramework2;
var
StatusText: string;
ResultCode: Integer;
begin
StatusText := WizardForm.StatusLabel.Caption;
WizardForm.StatusLabel.Caption := 'Installing Access Runtime files...';
WizardForm.ProgressGauge.Style := npbstMarquee;
try
if not Exec(ExpandConstant('{tmp}\AccessRuntime.exe'), '/q /noreboot', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
begin
// you can interact with the user that the installation failed
MsgBox('Access Runtime installation failed with code: ' + IntToStr(ResultCode) + '.',
mbError, MB_OK);
end;
finally
WizardForm.StatusLabel.Caption := StatusText;
WizardForm.ProgressGauge.Style := npbstNormal;
end;
end;
procedure InstallFramework3;
var
StatusText: string;
ResultCode: Integer;
begin
StatusText := WizardForm.StatusLabel.Caption;
WizardForm.StatusLabel.Caption := 'Installing Acrobar Reader';
WizardForm.ProgressGauge.Style := npbstMarquee;
try
if not Exec(ExpandConstant('{tmp}\AdbeRdr11010_en_US.exe'), '/q /noreboot', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
begin
// you can interact with the user that the installation failed
MsgBox('Acrobat installation failed with code: ' + IntToStr(ResultCode) + '.',
mbError, MB_OK);
end;
finally
WizardForm.StatusLabel.Caption := StatusText;
WizardForm.ProgressGauge.Style := npbstNormal;
end;
end;
[Icons]
Name: "{commonprograms}\{#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
Thanks Martin ! Your advise in removing the /q helped! Turns out that the accessruntime.exe does not allow the /noreboot....i changed it to /norestart... and it worked!
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;
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;