Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use multiple files with the same name with ExtractTemporaryFile?

Tags:

inno-setup

InnoSetup has a function ExtractTemporaryFile that can extract a file temporarily Instead of installing it). E.g. to extract and run a 3rd party installer during setup.

This function only takes a filename, so if there are multiple files with the same name you wish to treat this way, it doesn't work.

How can this be handled without renaming the source files?

like image 630
Martin Ba Avatar asked Oct 28 '25 03:10

Martin Ba


1 Answers

Has been answered on the InnoSetup user voice forum:

  1. The problem is, that InnoSetup doesn't know about the full source path of a file, it just has a list of files with destinations.
  2. While ExtractTemporaryFile cannot currently distinguish by destination directory, it is possible to rename the DestName so one can differentiate the files without renaming the source:

Example:

; 2005 redist
Source: Source\Redist\vcredist_x86.exe; Flags: dontcopy
; 2010 redist 
Source: Source\Redist\2010\vcredist_x86.exe; DestName: vcredist_x86_2010.exe; Flags: dontcopy

Later you can refer to the unique file names without having to rename the input to the setup.

Full credits go to dave


When you have a recent Inno Setup version, there's also ExtractTemporaryFile*s*, which can use wildcards by destination directory, so the way to go is:

[Files]
Source: Source\Redist\*.*; DestDir: redist_bundle; Flags: dontcopy recursesubdirs

[Code]
...
ExtractTemporaryFiles('redist_bundle\*');
//                _-^-_

This will extract the subtree below the Redist source to inno's temporary directory. Note that I omitted any {app} or {tmp} constant in the DestDir and subsequently also in the Extract.. function.

This way, the files will be extracted as, e.g.

...
[12:16:32,105]   Extracting temporary file: C:\Users\me\AppData\Local\Temp\is-xyz.tmp\redist_bundle\ucrt-redist-10586\Windows6.1-KB3118401-x64.msu
[12:16:32,145]   Extracting temporary file: C:\Users\me\AppData\Local\Temp\is-xyz.tmp\redist_bundle\vcredist-2005\vcredist_x86.exe
[12:16:32,167]   Extracting temporary file: C:\Users\me\AppData\Local\Temp\is-xyz.tmp\redist_bundle\vcredist-2010\vcredist_x64.exe
[12:16:32,230]   Extracting temporary file: C:\Users\me\AppData\Local\Temp\is-xyz.tmp\redist_bundle\vcredist-2010\vcredist_x86.exe
[12:16:32,279]   Extracting temporary file: C:\Users\me\AppData\Local\Temp\is-xyz.tmp\redist_bundle\vcredist-2013\vcredist_x64.exe
[12:16:32,318]   Extracting temporary file: C:\Users\me\AppData\Local\Temp\is-xyz.tmp\redist_bundle\vcredist-2013\vcredist_x86.exe
[12:16:32,358]   Extracting temporary file: C:\Users\me\AppData\Local\Temp\is-xyz.tmp\redist_bundle\vcredist-2015\vc_redist.x64.exe
[12:16:32,437]   Extracting temporary file: C:\Users\me\AppData\Local\Temp\is-xyz.tmp\redist_bundle\vcredist-2015\vc_redist.x86.exe
[12:16:32,512]   Extracting temporary file: C:\Users\me\AppData\Local\Temp\is-xyz.tmp\redist_bundle\vcredist-2017\vc_redist.x64.exe
[12:16:32,591]   Extracting temporary file: C:\Users\me\AppData\Local\Temp\is-xyz.tmp\redist_bundle\vcredist-2017\vc_redist.x86.exe
like image 200
Martin Ba Avatar answered Oct 30 '25 13:10

Martin Ba



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!