Jump to content

Zip folder with VBS


Guest jj_astral

Recommended Posts

Guest jj_astral

Hi,

I'm trying to write a Vb script that creates a .zip archive and adds a folder to it.

I've found this code example in one topic but actually it's not working, i think because FileSystemObject is used for that operation..

The code contains two parts, firts creates a blank .zip archive in C:\test1 directory, the second adds (should) C:\test2 folder's contents to that archive in C:\test1 . First part works, but when executing the second one it just does nothing...

So here is the code itself:

'Part 1

Set Ag=Wscript.Arguments
username = CreateObject("Wscript.Shell")_
.Environment("Process")("username")
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile("c:\test1\123.kmv", 8, vbtrue)
BlankZip = "PK" & Chr(5) & Chr(6)
For x = 0 to 17
BlankZip = BlankZip & Chr(0)
Next
ts.Write BlankZip
set objFolder = nothing
set objShell = nothing
Set fso = nothing
Set ts = nothing

'Part 2

Set objShell = CreateObject("Shell.Application")
Set WshShell = WScript.CreateObject("WScript.Shell")
Set DestFldr=objShell.NameSpace("C:\test1\123.kmv")
Set SrcFldr=objShell.NameSpace("c:\test2")
DestFldr.CopyHere ("c:\test2")

Any ideas?

Or if there is some other method to do that in vbs?

Thanks,

Link to comment
Share on other sites


  • 6 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...