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]: /Feature[Next]: FileComment
Have your say! Join the MAKEMSI discussion list or view archive! Suggest improvements. No question too simple or too complex.
\->Source Code->Commands->File

The "File" Command

This command adds a single file (no wildcards) to the MSI. It can add to a component or create a component for the file. The "Files" command uses this command to add files matching a wildcard you supply (optionally including all or part of a directory tree).

In general I use the "Files" command even for single files except when I need to do something it can't do (such as renaming files). Using the same command means I don't really have to remember the parameters of both!

Also have a look at the "Create Macro For Adding Files" tip for an example of one way of simplifying file addition.

I recommend that you read the "unversioned files" tip. You should at least consider this issue...

If you are adding a large number of files and this is a bit slow (probably the HTML generation) then you should have a look at the performance section! I recommend that you read the "Resource Life Cycle" section.

If MAKEMSI has problems and ignores (or doesn't find) files whose names or directories contain "international" characters then please see the documentation for the "MAKEMSI_MM_CODEPAGE" environment variable.

With the default MSI schema it can have a maximum of 32,767 files, however MAKEMSI will take a while to create this MSI and Windows Installer will be very slow to install and uninstall it. If you have large numbers of files I recommend you read the "performance" and "TABLES_FILE_SEQ_NUMBER_LIMIT" sections of this manual!

The command takes these parameters:

If you have a file containing the names of the files you'd like to include then have alook at the "Read a file List" tip.

SPECIAL PROCESSING

MAKEMSI normally generates HTML documentation and has special exception code to allow you to add this documentation to your MSI. To add the documentation you must use the "RowKey" defined by the macro "FILE_HTMLRPT_ROWKEY", for this one instance the file is allowed to be missing (it has not yet been generated) and some details will be filled in at the "compile" stage.

Main File Related Options

Please see the "options for commands" section of the manual.

#define? DEFAULT_FILE_WANT_FILEHASH                  T         ;;Generate MD5 (Y=YES, N=NO, T=TRY). MD5 needs Windows Installer 2.0+
#define? DEFAULT_FILE_ATTRIBUTES                     Vital     ;;Only use if user did not supply
#define? DEFAULT_FILE_ATTRIBUTES_TO_COPY                       ;;Choose one or more from hidden/system/readonly
#define? DEFAULT_FILE_LANG_WHEN_GETLANGUAGE_FAILS    1033      ;;Can be ""
#define? DEFAULT_FILE_ACCESS
#define? DEFAULT_FILE_REMOVE                         N         ;;Don't remove files by default!
#define? DEFAULT_FILE_DATE                                     ;;""= file date or date in "YYYY-MM-DD" (exactly 10 characters)
#define? DEFAULT_FILE_TIME                                     ;;""= file time or time in "HH:mm:SS"   (exactly 8 characters and seconds even)
#define? DEFAULT_FILE_DOCO                           Y         ;;"N" = Don't add to doco (by default)
#define? DEFAULT_FILE_OPTIONS4COMPONENT                        ;;Any options for autocreated components
#define? DEFAULT_FILE_OPTION_MAKE_REMOVE_DIRECTORIES Y         ;;Now make/remove directories by default
#define? FILE_HTMLRPT_INSTALLTIME_COMMENT_TEXT          *          ;;What the user sees
#define? FILE_HTMLRPT_INSTALLTIME_COMMENT_HTML          <span title='The install time of the file will be &quot;{?}&quot;'><font color=red><$FILE_HTMLRPT_INSTALLTIME_COMMENT_TEXT></font></span>     ;;Don't use Double quotes and ONLY the text in the "FILE_HTMLRPT_INSTALLTIME_COMMENT_TEXT" macro should be visible to user (or sorting won't work correctly)!!!
#define? FILE_GENERATED_COMPONENT_PREFIX                c          ;;Begins any components generated by the "file(s)" commands, followed by unique number ("" means don't add unique prefix)
#define? FILE_GENERATED_COMPONENT_USE_FILE_AS_KEYPATH   Y          ;;Must be "Y" unless you have set a keypath in the "Options4Component" parameter (in which case should be "N")!
#define? FILE_GENERATED_COMPONENT_MAX_LENGTH            <$TABLES_LNG_COMPONENT_COLUMN>  ;;Should be shorter than or equal to value in "TABLES_LNG_COMPONENT_COLUMN" (see doco for error code 2716)
#( ';'
   ;--- Semi colon (";") delimitered list of file extensions ----------------
   #define? FILE_EXTENSIONS_WHICH_NEED_OWN_COMPONENT    ;;"*" means all
   .exe
   .dll
   .ocx
   .hlp
   .chm
#)
#define? FILE_COMMAND_ALLOWED                                      ;;If not blank then not allowed and is the error message. You can use "{NL}" to represent newlines
#define? FILE_VERSION_FOR_UNVERSIONED_FILES
#define? DEFAULT_FILE_ROWKEY_CASE                                  ;;Can be "" or "L" or "U"
#define? DEFAULT_FILE_ROWKEY_MAXLNG               <$TABLES_LNG_FILE_COLUMN>-4   ;;0 = no restriction (this limit is WITHOUT any possible number added to make unique!)
#define? FILE_HTMLRPT_HR                          <$SUNDRY_HTMLRPT_HR>
#define? FILE_HTMLRPT_ROWKEY                      MAKEMSI_Documentation     ;;Name of special case which does not exist when code generated!
#define? FILE_HTMLRPT_MAX_EXTENSION_WIDTH         7
#define? FILE_STYLE_TEXT_ERROR                    color:red
#define? FILE_STYLE_TEXT_OK                       color:green
#define? FILE_VERIFY_STYLE_FILENAME_DEFAULT_LOCN  color:blue
#define? FILE_VERIFY_OUTPUT_BACKGROUND_COLOR      #dfdfdf
#define? FILE_VERIFY_SHOW_COMPONENT_OK_MESSAGE_WHEN_FILES_ALSO_OK N
#define? FILE_VERIFY_ATTRIBUTE_SET.H              <b>H</b>
#define? FILE_VERIFY_ATTRIBUTE_SET.R              <b>R</b>
#define? FILE_VERIFY_ATTRIBUTE_SET.S              <b>S</b>
#define? FILE_VERIFY_ATTRIBUTE_RESET.H            h
#define? FILE_VERIFY_ATTRIBUTE_RESET.R            r
#define? FILE_VERIFY_ATTRIBUTE_RESET.S            s

#( '<?NewLine>'
   #define? FILE_STYLES

   .FileCmtPlus             {font-size:9pt;}
   .FileCmtName             {<$HTMLRPT_STYLE_VALUES_KEY>}
   .FileCmtValue            {<$HTMLRPT_STYLE_VALUES_VALUE>}
   .FileCmtSFI              {color:maroon}
   <$FILE_STYLES_VERIFY>
   <$FILE_STYLES_VERIFY_COMPONENT_CHECKS>
#)
#( '<?NewLine>'
   #define? FILE_STYLES_VERIFY

   .FileVerify_DoesNotExist    {<$FILE_STYLE_TEXT_ERROR>}
   .FileVerify_FileNameDefault {<$FILE_VERIFY_STYLE_FILENAME_DEFAULT_LOCN>}
   .FileVerify_CantAccess   {<$FILE_STYLE_TEXT_ERROR>}
   .FileVerify_OK           {<$FILE_STYLE_TEXT_OK>}
   .FileVerify_MisMatch     {<$FILE_STYLE_TEXT_ERROR>}
   .FileVerifyNoActiveX     {<$FILE_STYLE_TEXT_ERROR>}
   .FileVerifyProductErr    {<$FILE_STYLE_TEXT_ERROR>}
   .FileVerifyProductOK     {<$FILE_STYLE_TEXT_OK>}
#)
#( '<?NewLine>'
   #define? FILE_STYLES_VERIFY_COMPONENT_CHECKS

   .FileVerify_ComponentUnmanaged                      {}
   .FileVerify_ComponentNotInstalledAndFileDoesntExist {<$FILE_STYLE_TEXT_OK>}
   .FileVerify_ComponentInstalledAndFileOk             {<$FILE_STYLE_TEXT_OK>}
   .FileVerify_GuidUnknown                             {<$FILE_STYLE_TEXT_ERROR>}
   .FileVerify_ComponentNotInstalledButFileOk          {<$FILE_STYLE_TEXT_ERROR>}
   .FileVerify_ComponentNotInstalledAndFileDoesntMatch {<$FILE_STYLE_TEXT_ERROR>}
   .FileVerify_ComponentInstalledButFileDoesntMatch    {<$FILE_STYLE_TEXT_ERROR>}
#)

EXAMPLE #1

;--- Set up some default file comments --------------------------------------
<$FileComment ".txt"  Comment="Text file">
<$FileComment ".exe"  Comment="Executable binary file">
<$FileComment ".dll"  Comment="Dynamic Link Library">
<$FileComment ".htm"  Comment="HTML">
<$FileComment ".html" Comment="HTML">
<$FileComment ".jpg"  Comment="Graphics file">
<$FileComment ".gif"  Comment="Graphics file">
<$FileComment ".asp"  Comment="Active Server Page">

;--- Create component and add some files ------------------------------------
<$Component "Fred" Create="Y" Directory_="INSTALLDIR">
   <$File Source="A file I Installed.txt">
   <$File Source="..\X\Another.txt">
   <$File Source="D:\DBAREIS\tools\where.exe">
   <$File Source="Slides.ppt" Destination="Slides.pps"> ;;Convert powerpoint to "Power Point Show"
   #(
       ;--- This source file has read-only set! -----------------------------
       <$File
                   Source="c:\winnt\welc.exe"
                  Comment=^This file has the read-only attribute set. It should get copied to the file table attributes!^
           CopyAttributes="ReadOnly Hidden"
       >
   #)

   ;--- Add some other files (demo default comment) -------------------------
   <$FileComment Comment="File required by xyz">
         <$File Source="required.exe">
         <$FileComment Comment="">
            <$File Source="NoDefaultCommentForThisFile.txt">
         <$/FileComment>
         <$File Source="required.dll">
   <$/FileComment>
<$/Component>

EXAMPLE #2 - Set File Access

<$Access "Admin(complete)"              Users="Administrators SYSTEM" Access="GENERIC_ALL">
<$Access "AuthenticatedUsers(ReadOnly)" Users=^'Authenticated Users'^ Access="GENERIC_READ GENERIC_EXECUTE">
#(
    <$File
                   Access="Admin(complete) AuthenticatedUsers(ReadOnly)"
                   Source="<$SOURCE_DIR>\SomeFile.ini"
              Destination="[INSTALLDIR]\SomeFile.ini"
        Options4Component=^ComponentId=''^              ;;Don't want repair or uninstall of this file
                   EXLIST="SomeFile.ini"
    >
#)


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]: /Feature[Next]: FileComment


MAKEMSI© is (C)opyright Dennis Bareis 2003-2008 (All rights reserved).
Friday October 13 2017 at 2:08pm
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.