Guest jj_astral Posted May 17, 2008 Share Posted May 17, 2008 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 1Set 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 17BlankZip = BlankZip & Chr(0)Nextts.Write BlankZip set objFolder = nothing set objShell = nothingSet fso = nothingSet ts = nothing'Part 2Set 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 More sharing options...
Guest jj_astral Posted May 18, 2008 Share Posted May 18, 2008 Hm... 28 views and no answers... Pitty... Link to comment Share on other sites More sharing options...
Trantwa Posted December 3, 2008 Share Posted December 3, 2008 Hi,I've been playing with this type of code reciently and all the examples I have seen haveWscript.sleep 500 in them which slows the code down so that the zip file can be created.Hope this helpsTrantwa Link to comment Share on other sites More sharing options...
JohnWessel Posted December 4, 2008 Share Posted December 4, 2008 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? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now