VBScript
VBScript
Create Password Protected Zip containing a Single File.
See more Zip Examples
Create a password-protected .zip containing a single file. (This uses the older Zip 2.0 encryption scheme, which is weaker and not as secure as AES encryption, which Chilkat Zip also supports.)Chilkat VBScript Downloads
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a Unicode (utf-16) output text file.
Set outFile = fso.CreateTextFile("output.txt", True, True)
success = 0
' This example requires the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.
set zip = CreateObject("Chilkat.Zip")
success = zip.NewZip("test.zip")
If (success = 0) Then
outFile.WriteLine(zip.LastErrorText)
WScript.Quit
End If
zip.SetPassword "secret"
zip.PasswordProtect = 1
saveExtraPath = 0
success = zip.AddFile("/temp/hamlet.xml",saveExtraPath)
success = zip.WriteZipAndClose()
If (success = 0) Then
outFile.WriteLine(zip.LastErrorText)
WScript.Quit
End If
outFile.WriteLine("Zip Created!")
outFile.Close