After building my appplication on Windows using maven (and a little bit of ant) I manually create a Winrar Sfx Installer as follows:
- Select files, right click and select Add to Archive
- Use Browse.. to create the archive in the folder above
- Change Archive Format to Zip
- Enable Create Archive Format
- Select Advanced tab
- Select SFX Options
- Select Setup tab
- Enter setup.exe into the Run after Extraction field
- Select Modes tab
- Enable Unpack to temporary folder
- Select text and Icon tab
- Enter new title
- Select setup.ico from the same folder that we invoked winrar from
- Select OK
- Select OK
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:
- Command line mode
- Command line syntax
- Commands
- Switches
- Self-extracting modules
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.