Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Windows XP and 2003 Native Zip/Unzip

 
Logged in as: Guest
arrSession:exec spGetSession 2,16,53086
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> Post a VBScript >> Windows XP and 2003 Native Zip/Unzip
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Windows XP and 2003 Native Zip/Unzip - 10/27/2007 12:31:01 AM   
  DiGiTAL.SkReAM


Posts: 1097
Score: 6
Joined: 9/6/2005
From: Florida, USA
Status: offline
I've been doing a lot of this lately, so figured I'd post it.

This allows you to ZIP all the files in a folder into a zip file, using Windows XP's native Compressed Folders functionality.  It doesn't give as good compression rates as WinZIP or WinRAR, but it has the added benefit of working on every Windows XP and 2003 computer, with no extra software.


      

This allows you to UNZIP all the files from a zip file into a folder.


      


_____________________________

"There's the one man who learns by reading, the two men that learn by watching, and the rest of us have to pee on the electric fence for ourselves." - Roy Rogers

"Would you like to touch my monkey?" - Dieter (Mike Meyers)
 
 
Post #: 1
 
 RE: Windows XP and 2003 Native Zip/Unzip - 10/27/2007 3:16:35 AM   
  dm_4ever


Posts: 2174
Score: 32
Joined: 6/29/2006
From: Orange County, California
Status: offline
http://www.visualbasicscript.com/m_46632/tm.htm

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to DiGiTAL.SkReAM)
 
 
Post #: 2
 
 RE: Windows XP and 2003 Native Zip/Unzip - 10/27/2007 4:20:46 AM   
  DiGiTAL.SkReAM


Posts: 1097
Score: 6
Joined: 9/6/2005
From: Florida, USA
Status: offline
Hokay, so I can't keep track of what I've posted and what I haven't. hehehehe



Sorry.

But hey, at least it isn't a 4 page advertisement for printers or cameras.

_____________________________

"There's the one man who learns by reading, the two men that learn by watching, and the rest of us have to pee on the electric fence for ourselves." - Roy Rogers

"Would you like to touch my monkey?" - Dieter (Mike Meyers)

(in reply to dm_4ever)
 
 
Post #: 3
 
 RE: Windows XP and 2003 Native Zip/Unzip - 10/27/2007 8:11:36 AM   
  dm_4ever


Posts: 2174
Score: 32
Joined: 6/29/2006
From: Orange County, California
Status: offline
No worries man , I'm sure someone will still ask if zipping is possible with VBScript and say they can't find examples. 

I saw those advertisements, deleted them, and notified the poster.

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to DiGiTAL.SkReAM)
 
 
Post #: 4
 
 RE: Windows XP and 2003 Native Zip/Unzip - 11/26/2007 11:10:28 AM   
  kich

 

Posts: 3
Score: 0
Joined: 10/27/2007
Status: offline
There is a question:
if there is a folder that has nothing in it ,i use this code to zip to a ZipFile,and somithing wrong occurs.i can't zippes the folder that there  is a empty folder in it.

so how can i do??

PS:I am a chinese,and the System display a dialog that show me wrong in chinese,so i can't tell you the details that the WSH says.

(in reply to DiGiTAL.SkReAM)
 
 
Revisions: 1 | Post #: 5
 
 RE: Windows XP and 2003 Native Zip/Unzip - 1/2/2008 9:02:01 AM   
  raygn

 

Posts: 2
Score: 0
Joined: 1/2/2008
Status: offline
I have tried this script which is very good and works.  I have also tried other similar scripts but.

I am trying to compress multiple folders to one zip file.

folder1 = C:\Folder1
folder2 = C:\Folder2
folder3 = C:\Documents and Settings\myuser\folder3

myzip = C:\Myzipfile.zip

WScript.Echo("Compressing Folder1")
fZip(folder1,myzip)
WScript.Echo("Compressing Folder2")
fZip(folder2,myzip)

This is where the script does not error nor does it work.  I have tried to do this multipe ways and same results it compresses the 1st folder then it just sits there.

I have tracked the problem down to this section of code in all the scripts I have tried.

zipcnt = oShellApp.NameSpace(myzip).Items.Count
newcnt = zipcnt + oShellApp.NameSpace(folder2).Items.Count

trying either of these lines causes the same thing it cannot read the items from the zip.  I have tried to do this manually also just read the items in a zip file and echo it out the same thing happens  Could you assist me or point me in the correct way of doing this. 

I need to copy the folder and all of its contents into the zip and do thise with multiple folders.

(in reply to DiGiTAL.SkReAM)
 
 
Post #: 6
 
 RE: Windows XP and 2003 Native Zip/Unzip - 1/5/2008 8:07:43 AM   
  DiGiTAL.SkReAM


Posts: 1097
Score: 6
Joined: 9/6/2005
From: Florida, USA
Status: offline
To answer the two quesitons:

1) Windows Xp Compressed Folders don't include empty folders.  But, as long as the empty folder is not int he root of the sourcefoler, you will be ok.
For example:

This won't work...
fZip "c:\dev", "c:\dev.zip"
with the following folder structure
c:\dev
c:\dev\folder1
c:\dev\This_is_an_empty_folder

But, this WILL work...
c:\dev
c:\dev\folder1
c:\dev\folder1\This_is_an_empty_folder


2) This script was written to just add the contents of a single folder to a single zip file.
I will look further into it, but just don't have the time right now.

_____________________________

"There's the one man who learns by reading, the two men that learn by watching, and the rest of us have to pee on the electric fence for ourselves." - Roy Rogers

"Would you like to touch my monkey?" - Dieter (Mike Meyers)

(in reply to raygn)
 
 
Post #: 7
 
 RE: Windows XP and 2003 Native Zip/Unzip - 1/6/2008 2:42:07 PM   
  raygn

 

Posts: 2
Score: 0
Joined: 1/2/2008
Status: offline
because I could not get this to work on multiple folders into one zip at the moment I had to take the long way about doing this.

I copy all files and folders I want to zip into a new folder I create and then zip this folder up it seems to work as for compressing everything up. It does however take an extremely long time to copy all the information before compressing. The script then suddenly just exists once it is done, even though it is supposed to let the user know it is complete and the zip file exists and sleep for 5 seconds to display the information before quiting.

I appreciate your help and will also continue to look for a method to compress multiple folders into one zip.

(in reply to DiGiTAL.SkReAM)
 
 
Post #: 8
 
 RE: Windows XP and 2003 Native Zip/Unzip - 3/2/2008 2:33:45 PM   
  alphasource

 

Posts: 1
Score: 0
Joined: 2/27/2008
Status: offline
Hi,

I was just wondering where and how would you define in the script the source folder and destination folder/file?

Thank you in advance,

Alpha

(in reply to DiGiTAL.SkReAM)
 
 
Post #: 9
 
 RE: Windows XP and 2003 Native Zip/Unzip - 3/2/2008 5:11:17 PM   
  DiGiTAL.SkReAM


Posts: 1097
Score: 6
Joined: 9/6/2005
From: Florida, USA
Status: offline
Um, it is a function that takes two arguments.
The arguments are named, oddly enough: sSourceFolder and sTargetZIPFile

I'm thinking that the argument sSourceFolder is probably the source folder and that sTargetZIPFile is most likely the destination zip file.

iResult = fZip("c:\myfolder", "c:\myzip.zip")

If iResult <> 0 then
    msgbox "There was an error"
end if


Also, the function is commented and documented so that you could read through it and find out the info.

_____________________________

"There's the one man who learns by reading, the two men that learn by watching, and the rest of us have to pee on the electric fence for ourselves." - Roy Rogers

"Would you like to touch my monkey?" - Dieter (Mike Meyers)

(in reply to alphasource)
 
 
Post #: 10
 
 RE: Windows XP and 2003 Native Zip/Unzip - 3/2/2008 5:16:12 PM   
  DiGiTAL.SkReAM


Posts: 1097
Score: 6
Joined: 9/6/2005
From: Florida, USA
Status: offline
quote:

ORIGINAL: raygn

because I could not get this to work on multiple folders into one zip at the moment I had to take the long way about doing this.

I copy all files and folders I want to zip into a new folder I create and then zip this folder up it seems to work as for compressing everything up. It does however take an extremely long time to copy all the information before compressing. The script then suddenly just exists once it is done, even though it is supposed to let the user know it is complete and the zip file exists and sleep for 5 seconds to display the information before quiting.

I appreciate your help and will also continue to look for a method to compress multiple folders into one zip.


There are limits as to what you can access via VBScript.  This is a method to utilize the built-in ZIP compression of Windows, via VBScript.  of course, there are going to be methods out there that will work and give greater functionality, speed, etc.  BUT, they wouldn't be native vbscript methods.  They are 3rd party utils.

If you are looking for something that is still not a packaged EXE, yet allows you to do this stuff via vbscript, you might consider paying a few hundred dollars for some of Chilkat's activeX objects.  I hear they are great.  Or, you could download and buy Winzip or WinRAR and call them from the commandline via vbscript.


_____________________________

"There's the one man who learns by reading, the two men that learn by watching, and the rest of us have to pee on the electric fence for ourselves." - Roy Rogers

"Would you like to touch my monkey?" - Dieter (Mike Meyers)

(in reply to raygn)
 
 
Post #: 11
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> Post a VBScript >> Windows XP and 2003 Native Zip/Unzip Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts