|
How
to Create a Self-Extracting EXE
Using Chilkat Zip ActiveX Compression v9.4.0
Chilkat
Zip v9.4.0 provides a new method, WriteExe, that makes it easy
to create a self-extracting EXE. You can create an EXE with or
without AES (Rijndael) encryption. If your self-extracting EXE
is encrypted, it can be 128-bit, 192-bit, or 256-bit AES. There
is also the option of designating an auto-run executable within
your Zip to be run after the self-extracting EXE is unzipped.
And finally, you can create EXEs that automatically unzip to a
system-chosen and created temp directory when the EXE is double
clicked. Using the "AutoTemp" property in combination
with the "AutoRun" property makes it easy to create
single-click installers.
Here
are some VB examples demonstrating how to use WriteExe, AutoRun,
and AutoTemp.
' Create a Simple Self-Extracting EXE
Private Sub Command1_Click()
Dim zip As ChilkatZip
Set zip = New ChilkatZip
zip.UnlockComponent "22540E510A3140"
zip.NewZip "notUsed.zip"
zip.AppendFiles "Sample/*", 1
zip.WriteExe "sample.exe"
zip.SaveXmlLog "log.xml"
End Sub
' Create an AES Encrypted Self-Extracting EXE
Private Sub Command2_Click()
Dim zip As ChilkatZip
Set zip = New ChilkatZip
zip.UnlockComponent "22540E510A3140"
zip.NewZip "notUsed.zip"
zip.AppendFiles "Sample/*", 1
' Setting encryption to non-zero causes Rijndael AES encryption to
' be used in the self-extracting EXE.
zip.Encryption = 1
' Key lengths can be 128, 192, or 256
zip.EncryptKeyLength = 256
zip.SetPassword "chilkat"
zip.WriteExe "encrypted.exe"
zip.SaveXmlLog "log.xml"
End Sub
' Create an Auto-Run Self-Extracting EXE
Private Sub Command3_Click()
Dim zip As ChilkatZip
Set zip = New ChilkatZip
zip.UnlockComponent "22540E510A3140"
' AutoTemp and AutoRun control what kind of self-extracting EXE
' is created. If AutoRun is set, the EXE will automatically
' run the specified EXE after unzipping. If AutoTemp is 1
' the self-extracted EXE will automatically unzip to a TEMP
' directory when double-clicked.
zip.AutoTemp = 1
zip.AutoRun = "Sample\Setup.exe"
zip.NewZip "notUsed.zip"
zip.AppendFiles "Sample/*", 1
zip.WriteExe "autoRun.exe"
zip.SaveXmlLog "log.xml"
End Sub
' Create an Auto-Run AES Encrypted Self-Extracting EXE
Private Sub Command4_Click()
Dim zip As ChilkatZip
Set zip = New ChilkatZip
zip.UnlockComponent "22540E510A3140"
' AutoTemp and AutoRun control what kind of self-extracting EXE
' is created. If AutoRun is set, the EXE will automatically
' run the specified EXE after unzipping. If AutoTemp is 1
' the self-extracted EXE will automatically unzip to a TEMP
' directory when double-clicked.
zip.AutoTemp = 1
zip.AutoRun = "Sample\Setup.exe"
zip.NewZip "notUsed.zip"
zip.AppendFiles "Sample/*", 1
' Setting encryption to non-zero causes Rijndael AES encryption to
' be used in the self-extracting EXE.
zip.Encryption = 1
' Key lengths can be 128, 192, or 256
zip.EncryptKeyLength = 256
zip.SetPassword "chilkat"
zip.WriteExe "encryptedAutoRun.exe"
zip.SaveXmlLog "log.xml"
End Sub
|