' Create an empty ZIP file
Set objFSO = CreateObject( "Scripting.FileSystemObject" )
Set objTxt = objFSO.OpenTextFile( myZipFile, ForWriting, True )
objTxt.Write "PK" & Chr(5) & Chr(6) & String( 18, Chr(0) )
objTxt.Close
Set objApp = CreateObject( "Shell.Application" )
' Copy the files into the ZIP file
objApp.NameSpace( myZipFile ).CopyHere objApp.NameSpace(
myFolder ).Items
' Keep script waiting until compression is done
Do Until objApp.NameSpace( myZipFile ).Items.Count _
= objApp.NameSpace( myFolder ).Items.Count
WScript.Sleep 200
Loop
The script creates the zip file and does the copy just fine.
I need to put the zip file onto a CD for backup purposes but I'd like to
protect the contents from prying eyes.
Is there a way to password protect the zip file without using third party
software?
Thanks for any help you can offer.
Tony
--
Jeffery Hicks MCSE, MCSA, MCT
Microsoft PowerShell MVP
http://www.scriptinganswers.com
http://www.powershellcommunity.org
http://jdhitsolutions.blogspot.com
Now Available: WSH and VBScript Core: TFM
Now Available: Windows PowerShell v1.0: TFM 2nd Ed.
"TonyR" <terpar@shaw[remove].ca> wrote in message
news:ZP5qj.45616$4w.19441@pd7urf2no...
> "TonyR" <terpar@shaw[remove].ca> wrote in message
>
> news:ZP5qj.45616$4w.19441@pd7urf2no...
>
> > I have a script which contains the following code to create a zip file and
> > copy several files into it using Windows Shell.
>
> > ' Create an empty ZIP file
{snip}
>
> > Is there a way to password protect the zip file without using third party
> > software?
>
> > Thanks for any help you can offer.
> > Tony
>
> Windows compressed files don't have a password option and you can't encrypt
> a Windows compressed file either.
>
> --
> Jeffery Hicks MCSE, MCSA, MCT
> Microsoft PowerShell MVPhttp://www.scriptinganswers.comhttp://www.powershellcommunity.orghttp://jdhitsolutions.blogspot.com
>
> Now Available: WSH and VBScript Core: TFM
> Now Available: Windows PowerShell v1.0: TFM 2nd Ed.
Are you sure? I just checked my XP system and when I right-click in a
"Windows" compressed folder, there is an option to "Add a Password".
That would imply the Shell.Application can invoke that verb ("Add a
Pass&word") to do the job. I don't *know* it will work, since this
capability is supplied to MS by a third party, but it seems as if it
just might be possible. I don't have the time to pursue this.
Further, my quick check of the registry suggests that the verb might
NOT be supported in a way that would allow it to be accessed via the
Shell.Application interface.
Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/
Hi, Tony
I don't have any help with the password thing. I seem to recall that
in the days of PKZip, the password was rather weak. I think I once
downloaded and tested a password cracker that worked with the
passwords I tried. I could be wrong on this, though, and M$ may be
doing it better than PKWare did it.
A couple of comments on your script:
1) I got errors in the checking loop:
> Do Until objApp.NameSpace( myZipFile ).Items.Count _
> = objApp.NameSpace( myFolder ).Items.Count
> WScript.Sleep 200
> Loop
Wrapping these lines in
On Error Resume Next ... On Error GoTo 0
fixed that problem.
2) It was not obvious from the error messages I received that both
myZipFile and myFolder must be complete file paths; relative paths
don't seem to work.
Thanks for posting the script.
-Paul Randall
Tony
"Paul Randall" <paul...@cableone.net> wrote in message
news:%23MGHb%23PaIH...@TK2MSFTNGP03.phx.gbl...
Can you send my a full vbs file?
I´m dummy.
tks