Jump to content

Recommended Posts

Guest jj_astral
Posted

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,


Guest jj_astral
Posted

Hm... 28 views and no answers...

Pitty...

  • 6 months later...
Posted

Hi,

I've been playing with this type of code reciently and all the examples I have seen have

Wscript.sleep 500

in them which slows the code down so that the zip file can be created.

Hope this helps

Trantwa

Posted

I can get this script to work in XP, but when I try to use it on a remote box under Win 2003, it creates the zip file, but won't move anything into it. Any ideas of how this might be done?

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...