Windows Scripting
  Home arrow Windows Scripting arrow Compressed Folders in WSH
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
WINDOWS SCRIPTING

Compressed Folders in WSH
By: Nilpo
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-12-29

    Table of Contents:
  • Compressed Folders in WSH
  • Creating a Binary file
  • Getting a Byte Array in VBScript
  • Adding and Extracting files

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Compressed Folders in WSH


    (Page 1 of 4 )

    Windows XP provides built-in zip file support in a feature referred to as Compressed Folders. While the compression of a Compressed Folder is not as effective as many third-party implementations, it does offer great compatibility since it is natively supported on all modern Windows platforms.

    For whatever reason, Microsoft did not include any scripting support for creating Compressed Folders.  There isn’t any viable command line for creating them either.  So that’s that; we shed our tears and walk away.

    But then again, that wouldn’t make for a very interesting article, and there’s a good chance my editors might have something to say about it when it comes time to pay me.  So I guess we’ll have to make a workaround.

    Compressed folders are implemented as a Windows Shell extension.  They are available in the context menu from within Windows Explorer.  Typically we would start looking here for a workaround, since we can often execute context menu items using the InvokeVerb method of the Windows Shell’s scripting interface.  However, the Compressed Folder item appears in the New menu and we don’t have access to that.

    That pretty much exhausts every avenue of automating the feature itself.  Let’s take a look at creating the file directly.  To do that you’ll need a hex editor like XVI32.  A hex editor allows you to open and view binary files like the Compress Folders in which we’re so interested.

    If you were to create a Compressed Folder in Windows Explorer, you would notice that it is nothing more than a .zip file.  If we open that empty .zip file in a hex editor, we may be able to see its binary composition and duplicate it to create our own zip files.

    As it turns out, Compressed Folders are actually very basic binary files that consist of a series of twenty-two bytes as follows:

    50 4B 05 06 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

    Each two-digit pair represents a single byte.  This number is a hex value that represents some character.  For example, 50 in hex equals 80 in decimal.  The ASCII code for character 80 is the capital letter P.  I’m going to spare myself the lengthy explanation here since we’re going to be working with the values that we see here.  Essentially, this file has the letters PK followed by a series of non-printable characters.

    More Windows Scripting Articles
    More By Nilpo


       · Hello,I was looking for this a long time!Great job!
       · Thank you very much.
     

    WINDOWS SCRIPTING ARTICLES

    - More Windows Scripting Workarounds from Nilpo
    - Overloading Methods and More in VBScript
    - Improving MFC for Windows Vista
    - Regular Expressions in VBScript
    - Working with Dates in WMI
    - Completing Calendars with VBScript Date Func...
    - Building Calendars with VBScript Date Functi...
    - Working With Dates and Times in VBScript
    - Designing WCF DataContract Classes Using the...
    - Understanding Dates and Times in VBScript
    - Working With Arrays in VBScript
    - Compressed Folders in WSH
    - Using .NET Interops in VBScript
    - Nilpo`s Scripting Secrets, Vol I
    - Database operations using Silverlight 2.0 WC...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    Stay green...Green IT