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]: File Version Compare Code[Next]: Folder Attributes - Reapply at Install Time
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->Files In Use - ADD

Files In Use - ADD

The windows "MakeCab.EXE" doesn't compress files which are in use which is fair enough, what is not good is that there is no option to override this.

The easiest way to work around this is to copy the file to another location and add the copy. Note that this may or may not be "safe" depending on the application holding the file open, you will need to test. I'm also not sure if "MAKECAB.EXE" only cares about files opened for write or if read-only access also causes issues.

If the copy also fails then the application is preventing read access and there is nothing you can do about this.

;--- Macro to make a copy of a file and add this to the current component ---
#(
    #define AddPossiblyInUseFile

    ;--- Need a local copy ("MAKECAB.EXE" fails if opened in "Excel" etc) ---
    #DefineRexx ''
        ;--- Make sure copy directory exists --------------------------------
        @@CopyDir = '<$MAKEMSI_OTHER_DIR>\CopiesOfPossiblyInUseFile';
        call MakeDirectoryTree @@CopyDir, "Y" ;     ;;Make sure directory exists

        ;--- Copy the file --------------------------------------------------
        @@SrcName  = '{$#1}';
        @@CopyName = @@CopyDir || '\' || FilePart('n', @@SrcName);
        call FileCopy @@SrcName, @@CopyName;

        ;--- What comment will we use? --------------------------------------
        @@Add2Comment = wbr('This file copied from "' || @@SrcName || '" as "MAKECAB.EXE" fails if a file is in use!');
        {$Comment $$RxVar:@@Comment};
        if  @@Comment <> '' then;
            @@Comment = @@Comment || ' ';
        @@Comment = @@Comment || @@Add2Comment;
    #DefineRexx

    ;--- Add the local copy -------------------------------------------------
    <$Files "<??@@CopyName>" KeyFile="*" Comment=^<??@@Comment>^>
#)

;--- Add the files ----------------------------------------------------------
<$Component "MayBeInUse" Create="Y" Directory_="INSTALLDIR">
    <$AddPossiblyInUseFile "\\SomeServer\SomeShare\SomeDir\SomeFile1.xls">
    <$AddPossiblyInUseFile "\\SomeServer\SomeShare\SomeDir\SomeFile2.doc">
<$/Component>


Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006, 2007, 2008 & 2009 for the Windows SDK (Windows Installer) area.Please email me any feedback, additional information or corrections.
See this page online (look for updates)

[Top][Contents][Prev]: File Version Compare Code[Next]: Folder Attributes - Reapply at Install Time


MAKEMSI© is (C)opyright Dennis Bareis 2003-2008 (All rights reserved).
Saturday May 28 2022 at 3:11pm
Visit MAKEMSI's Home Page
Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006, 2007, 2008 & 2009 for the Windows SDK (Windows Installer) area.