I've written a PowerShell script that creates a Self-Extracting Archive (a.k.a. SFX) executable file with WinRAR command-line. The problem is that the VERSIONINFO metadata is completely empty (accessed by right-clicking the *.exe
file that was built, going to Properties, and clicking on the Details tab).
Here is the WinRAR command I'm using in my script:
$WinRarInstallPath = "$Env:ProgramFiles\WinRAR\winrar"
<#
WinRAR arguments used:
a - Add files to an archive
-cfg- - Ignore default profile and environment variable
-ep1 - Exclude base folder from names
-iadm - Request administrative access for SFX archive
-iicon - Path to icon to use for installer
-r - Recurse subfolders
-sfx - Create self-extracting archive
-z - Path to archive comment file (SFX configuration file)
#>
&$WinRarInstallPath a -cfg- -ep1 -iadm -iicon"$IconPath" -r -sfx -z"$ConfigFilePath" `
"$InstallerName" "$SourceFilesPath\*" | Out-Null
Is there a command-line switch for WinRAR that can allow me to fill in the version and copyright information? If not, is there some way to fill that information in after the SFX's *.exe
file is built?
I was able to solve this by manually adding the VERSIONINFO file to a copy of WinRAR's Default64.SFX
file (found in WinRAR's installation path) and then using that to build the SFX. Here are the steps:
Default64.SFX
file to somewhere on your hard drive (like your Desktop).Default64.SFX
file that you copied in step 1 to Default64.exe
.Default64.exe
in Visual Studio (You may need to open Visual Studio, select File -> Open -> File, then click the arrow on the right side of the Open button and click on Open With.... Then in the Open With dialog that opens, select Resource Editor and click the OK button).Default64.exe
) and click on Add Resource. Select Version in the list and click the New button. If there was a Version folder, simply double-click the file in the folder.Default64.exe
back to Default64.SFX
.-sfx
switch, specify the path to the Default64.SFX
file you modified:&$WinRarInstallPath a -cfg- -ep1 -iadm -iicon"$IconPath" -r -sfx"C:\path\to\Default64.SFX" `
-z"$ConfigFilePath" "$InstallerName" "$SourceFilesPath\*" | Out-Null