CreateSDA Method
Compresses the files and creates a self-decrypting archive.
Syntax
sda.createSDA([callback])
Callback
The 'callback' parameter specifies a function which will be called when the operation completes (or an error is encountered). If the 'callback' parameter is not specified, then the method will block and will not return until the operation completes (or an error is encountered).
The callback for this method is defined as:
function(err){ }
'err' is the error that occurred. If there was no error, then 'err' is 'null'.
'err' has 2 properties which hold detailed information:
err.code err.message
Remarks
Invoking CreateSDA creates the archive specified by ArchiveFile. When the method is called, all files specified by SourceDirectory will be compressed and written to ArchiveFile. If RecurseSubdirectories is true, all the subdirectories under SourceDirectory and the files they contain will also be compressed and written to ArchiveFile.
If ArchiveFile exists when you call CreateSDA it will be overwritten.
As the files in SourceDirectory are being compressed, the 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 CaptionText before calling CreateSDA. Setting the optional BannerText 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-Decrypting Archive)
class.ArchiveFile = "c:\test.exe" class.RecurseSubdirectories = true class.SourceDirectory = "c:\foo\" class.CaptionText = "Testing SDA" class.BannerText = "Press continue to decompress the archive." class.CreateSDA() class.ArchiveFile = "c:\test.exe" class.SourceFile = "c:\foo\bar.dat" class.CaptionText = "Testing SDA" class.BannerText = "Press continue to decompress the archive." class.CreateSDA()
Note: When creating a self-decrypting archive which exceeds 4 GB or more of uncompressed data or which contains more than 64K files, the class will create a 64-bit archive.
The self-decrypting archive that is created by the SDA 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 ExtractToPath. "." indicates the current directory (if no ExtractToPath 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 FileToExecute. (Alternatively, set FileToExecute 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:
SDAExtractor /targetpath="." /overwrite=1 /displaymessage=0 /openfile=0 /password=pass
Note that if you run the self-decrypting archive with any command line options, the pop up message box containing the BannerText will be suppressed.