create_sfx Method
Compresses the files and creates a self-extracting archive.
Syntax
def create_sfx() -> None: ...
Remarks
Invoking CreateSFX creates the archive specified by archive_file. When the method is called, all files specified by source_directory will be compressed and written to archive_file. If recurse_subdirectories is true, all the subdirectories under source_directory and the files they contain will also be compressed and written to archive_file.
If archive_file exists when you call CreateSFX it will be overwritten.
As the files in source_directory are being compressed, the on_progress event will fire periodically to indicate how many bytes have been processed and the percentage of compression that has been completed.
To include your own custom text on the title bar of all of the self-extractor dialog boxes, set the caption_text before calling CreateSFX. Setting the optional banner_text property will cause a small dialog to pop up when the self-extractor is run. You can put in a description of the contents, instructions, or any text you like.
Example (Creating a Self-Extracting Archive)
class.ArchiveFile = "c:\test.exe" class.RecurseSubdirectories = true class.SourceDirectory = "c:\foo\" class.CaptionText = "Testing ZipSFX" class.BannerText = "Press continue to decompress the archive." class.CreateSFX()
Note: When creating a self-extracting archive which exceeds 4 GB or more of uncompressed data or which contains more than 64K files, the class will create a 64-bit Zip archive.
The self-extracting archive that is created by the ZipSFX class is a Windows application. However, there are command line options available if you wish to batch multiple files. The options are:
Option Name | Description |
targetpath | Path to decompress the archive to. This overrides the extract_to_path. "." indicates the current directory (if no extract_to_path was specified and no targetpath is given, the archive is decompressed to the current directory). |
overwrite | If set to true, the archive will automatically overwrite existing files (thus suppressing the message box asking you to overwrite or not) |
displaymessage | If set to false, it will suppress the display of the "Extraction Complete" message after the archive has finished (this may also be accomplished by setting the CompleteMessage config setting to ""). |
openfile | If set to false, this option will override opening the file indicated by file_to_execute. (Alternatively, set file_to_execute to ""). |
password | The password used to decrypt the archive. If the archive is not encrypted this option is ignored. However if the archive is encrypted and no password is supplied, decompression will fail. |
For example, the following suppresses all questions and message boxes, and decompress to the current
directory, use the following options:
ZipExtractor /targetpath="." /overwrite=1 /displaymessage=0 /openfile=0 /password=pass
Note that if you run the self-extracting archive with any command line options, the pop up message box containing the banner_text will be suppressed.