I have to zip all the files in a folder and make it password protected.
I googled and found one solution which uses the inbuilt functionality of Windows. The code goes like below:
folder1 = "F:\WLMS_TEAM\TOUHID\Script"
zipfile = "F:\WLMS_TEAM\TOUHID\MyTmp.zip"
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.OpenTextFile(zipfile, 8, True).Write "PK" & Chr(5) & Chr(6) _
& String(18, Chr(0))
Set ShellApp = CreateObject("Shell.Application")
Set zip = ShellApp.NameSpace(zipfile)
zip.CopyHere folder1
WScript.Sleep 2000
Can I make it password protected?
Or if you can help with some other code to use WinZip (not any other tool) to achieve the same.
Or It would be ok to have a separate code to password protect a pre-generated zip file.
You can run WinZip on the command-line like this:
Wrapped in VBScript:
I don't think the
Shell.Application
object allows the creation of password-protected zip files.