After building my appplication on Windows using maven (and a little bit of ant) I manually create a Winrar Sfx Installer as follows:
But can I automate some/all of this using Windows batch file/ Maven or ant ?
Start WinRAR, click in menu Help on Help topics and open tab Contents. You see there the list items:
All information you need to call WinRAR.exe with the right switches to create an SFX can be found in those help articles.
In general there are two possibilities:
You do what you have already done, but before clicking on final OK, you click on button Profiles on tab General and click on list item Save current settings to a new profile. Then you can call WinRAR.exe with switch "-cpMy SFX Profile". Read the help page for this switch.
You specify all options for creating the SFX archives directly on command line.
For the second possibility something like below can be used as template.
"%ProgramFiles%\WinRAR\WinRAR.exe" a -afzip -cfg- -ed -ep1 -k -m5 -r -tl -iicon"Path to icon file\MyApplicationInstall.ico" "-sfx%ProgramFiles%\WinRAR\Zip.sfx" "-zComment file with full path containing SFX options" "Path to Destination Folder\MyApplicationInstall.exe" "Path to files to add to archive\*"
The content for the *.txt comment file for switch -z
can be copied from tab Comment of the dialog opened for creating the archive after selecting all the SFX options.
By the way: I would suggest creating RAR self-extracting archives instead of ZIP self-extracting archives as with RAR compression the EXE file with the right switches for best compression using additionally also solid archive options could be much smaller than with ZIP compression.
So you don't need a batch file or any other application to create a WinRAR SFX archive. A simple shortcut file (*.lnk) with the right command line is all you need to create the SFX archive with a double click on this shortcut whenever you want to create a new SFX for your application.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With