\
Tips and Tricks
File and Directory
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>