Zip file and password protect it


I need zip and password protect a file. I have a directory in which a file will be placed on a daily basis. I need vb code that zips and password protects the zipped filed. the zipped file will inherit the unzipped file name. the file name will be the password.

I need this code for windows server 64bit or 32 bit. I need to run it from a scheduled task.

Unfortunately my vb is crap so I’m not sure how to code it.


Just wanted to mention that its got to be vbs rather than vb

I now have some code that zips a file, but how can i modify it such that it

  1. it dynamially picks the file in the directroy to zip
  2. passwords protect it using the name of the file
  3. works with large files

here is the code:


Const File1 = "C:\\files\	est.txt"

Const MyZip = "C:\\files\"

CreateObject("Scripting.FileSystemObject") _
.CreateTextFile(MyZip, True) _
.Write "PK" & Chr(5) & Chr(6) & String(18, vbNullChar)

'-------------- zip ---------------------------

'get ready to add files to zip
With CreateObject("Shell.Application")

'add files
.NameSpace(MyZip).CopyHere File1, FOF_CREATEPROGRESSDLG

.NameSpace(MyZip).CopyHere File2

End With
wScript.Sleep 1000

wscript.echo "Done!"