MAKEMSI quickly and reliably creates MSI files in a non-programmatic way
Have your say! Join the MAKEMSI discussion list or view archive! Suggest improvements. No question too simple or too complex.
[Bottom][Contents][Prev]: Update Hosts File[Next]: Finding 'WSCRIPT.EXE' or 'CSCRIPT.EXE' Files
Have your say! Join the MAKEMSI discussion list or view archive! Suggest improvements. No question too simple or too complex.
\->Tips and Tricks->File and Directory->ZIP Images for Directory Trees

ZIP Images for Directory Trees

You could have an unpacked image from a CD-ROM or similar but sometimes its just easier to manage and version control (with PVCS etc) a single file.

I like this approach when a 3rd party product changes infrequently and you'd generally want to replace the complete old image with a complete new one (so I don't really/often need to know exactly which file(s) in the image changed).

Sample Code Which Uses the Macro

;--- Unzip the image --------------------------------------------------------
#define UNZIPPED_IMAGE_DIR   <$MAKEMSI_OTHER_DIR>\UnpackedZips\product.zip  ;;This directory ERASED then recreated
<$UnzipImage ZipFile="c:\tmp\product.zip" Dir="<$UNZIPPED_IMAGE_DIR>">

;--- Add the files (components generated) -----------------------------------
<$Files "<$UNZIPPED_IMAGE_DIR>\*.*" DestDir="INSTALLDIR" SubDir="TREE" Comment=^Extracted from "product.zip".^>

The Macro Code

#(
    #define UnzipImage                                  ;;Version 07.146
    #evaluate ^^ ^<$@@Rexx2UnzipDirectoryTree {$?}>^
#)
#define? UnzipImageOutputColor  {CYAN}          ;;Output of the unzipping process..
#DefineRexx '@@Rexx2UnzipDirectoryTree'
    ;--- Get parameters -----------------------------------------------------
    {$!:ZIPFILE,DIR,CLEAR,Options}         ;;Validate passed parameters
    @@ZipFile              = '{$ZipFile}';
    @@DestinationDirectory = '{$Dir}';
    if  FileQueryExists(@@ZipFile) = '' then
        error('The zip file "' || @@ZipFile || '" doesn''t exist!');

    ;--- Almost always want to start with a clean directory -----------------
    if  '{$Clear=^Y^}' = 'N' then             ;;Allow for multiple zips unpacking into a single location.
        call Info 'Adding unpacked image to the destination directory.'
    else
    do
        ;--- We expect to start from scratch --------------------------------
        call Info 'Clearing the unzip destination directory'
        call AddressCmd 'rd "' || @@DestinationDirectory || '" /q /s >nul <$Stderr2Out>'

        ;--- We will need to create the directory ---------------------------
        call AddressCmd 'md "' || @@DestinationDirectory || '" >nul <$Stderr2Out>'
    end;

    ;--- Unzip --------------------------------------------------------------
    call Info 'Unpacking ZIP (' || @@ZipFile || ')'
    call ColorCfg '?UNZIPSRCIMG', '<$UnzipImageOutputColor>';
    call ColorSet '?UNZIPSRCIMG';
    @@Rc = AddressCmd('iunzip.exe {$Options=^-o^} "' || @@ZipFile || '" -d "' || @@DestinationDirectory || '"')
    call ColorSet 'DEFAULT';
    if  @@Rc <> 0 then
        error('The unzip of "' || @@ZipFile || '" failed with return code ' || @@Rc);
    else
    do
        ;--- Make sure we find at least one (non-hidden) file (double check) ---
        call Files4Mask @@DestinationDirectory || "\*.*", "@@ZipImage", "Y", "N"
        if  @@ZipImage.0 = 0 then
            error('The unzip of "' || @@ZipFile || '" probably failed as no files seem to have been extracted to the directory "' || @@DestinationDirectory || '"');
    end;
#DefineRexx


Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006 & 2007 for the Windows SDK (Windows Installer) area.This external link was OK when tested at 27 Dec 2008Please email me any feedback, additional information or corrections.
See this page online (look for updates)

[Top][Contents][Prev]: Update Hosts File[Next]: Finding 'WSCRIPT.EXE' or 'CSCRIPT.EXE' Files


MAKEMSI© is (C)opyright Dennis Bareis 2003-2008 (All rights reserved).
Saturday December 27 2008 at 3:15pm
Visit MAKEMSI's Home PageThis external link was OK when tested at 7 Dec 2008

HTML page dated Mon, 29 Jan 2007 00:11:11 GMT
Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006 & 2007 for the Windows SDK (Windows Installer) area.This external link was OK when tested at 27 Dec 2008