Quantcast
Channel: VBForums - ASP, VB Script
Viewing all articles
Browse latest Browse all 681

zip file and password protect it - please help

$
0
0
My vbs code below takes specified file and zipps it. I need to amend it such that:

1) it dynamically picks the file in the directory C:\files\ . I don’t want to declare the file name in the code.
2) passwords protect it using the name of the file. so if the file was called file123.txt, than the password is "file123"

I have been struggling to make get this working especially since I'm not a vbs coder
code:

Code:

Const FOF_CREATEPROGRESSDLG = &H0&

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

Const MyZip = "C:\files\test.zip"


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!"


Viewing all articles
Browse latest Browse all 681

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>