Export (0) Print
Expand All

Manipulating Folders and Files by Using Setup Information (.inf) Files

You can use .inf files to manipulate files and folders in several ways. Some key ways that are reviewed in this section are:

  • Creating folders and links in folders

  • Creating and deleting long file names

  • Setting attributes for files and folders

  • Copying files to the Program Files folder

On This Page

Creating Folders and Links in Folders
Creating and Deleting Long File Names
Setting Attributes for Files and Folders
Copying Files to the Program Files Folder
Limitations of .inf Files

Creating Folders and Links in Folders

Creating a folder in the Program Files folder or creating links in a folder is done by the shell after a component is installed. Setup looks in the Setup.ini file for a [progman.groups] section and then parses it to create folders and links in those folders.

If you are installing a component that will require a folder or links in the Program Files folder, create an UpdateInis section (refer to the Update .ini File sections (UpdateInis) information on the Setup Information File (.inf) Definition page) that will create the proper entries in the Setup.ini file. The Setup.ini file uses the following syntax to create folders and links. Note that folders are relative to the Start menu.


Link-Name, .exe-name, Icon-file-name, Icon-index, profile

If the profile field is left NULL, the link will always be added to the folder.

Note Note 

  • If .exe-name is a NULL item, it is deleted from the group if it exists there.

  • If a folder or link has a space in its description, you must use double quotation marks to get this to show up in the Setup.ini file. See the examples below.

    Example: Games

    [Optional Components]
    OptionDesc= %GAMES_DESC%
    CopyFiles= wingames.files
    UpdateInis= wingames.links
    setup.ini, progman.groups,, "gamesfolder=%GAMES_DESC%" ;creates folder
    setup.ini, gamesfolder,, """Solitaire Game"",SOL.EXE,,," ;creates link
    setup.ini, gamesfolder,, "Minesweeper,WINMINE.EXE,,," ;creates link
    setup.ini, gamesfolder,, ""Hearts Card Game"",MSHEARTS.EXE,,,";creates link
    setup.ini, gamesfolder,, "FreeCell,FREECELL.EXE,,," ;creates link

Result:   The entry for "Games" appears in the Optional Components dialog box in Setup, and if selected, a Games folder is created in the Program Files folder with links to Solitaire, Minesweeper, Hearts, and FreeCell.

Creating and Deleting Long File Names

The root branch of the registry for rename operations is the following:


The root branch of the registry for delete operations is the following:


Each group of rename and delete operations is added to a subkey under each branch. Each group of operations is limited to renaming or deleting files in a single folder. You must include a minimum of two entries in each subkey to effect a rename or delete: the folder path for the files to be renamed or deleted, and the actual rename or delete operation.

The first key in each group of operations is the folder entry. Each entry for a rename operation in the related folder is an entry of the form "old_short_name"="new_long_name,[attrib_flag]".

The optional attrib_flag is used to set file attributes during the rename operation. The flag is composed of the following values.







To set multiple attributes on a file or folder, the flags are added together; for example, to set the READONLY and HIDDEN attributes, attrib_flag would be 3.

The following example is an AddReg section that sets the SYSTEM and HIDDEN attributes for the \Windows\system32\Sample folder:


Note Note 

  • You should use all capital letters to ensure that the file name remains a short file name.

Each entry for a delete operation in the related folder is an entry of the form "arbitrary_key_name"="long_name_to_delete".

The following example is an AddReg section that:

  • Renames Oldname.txt file to New Long Name.txt in the C:\Samples folder.

  • Renames Myreadme.txt file to My Application Readme.txt in the Windows folder.

    Long Name.txt"
    HKLM,Software\Microsoft\Windows\CurrentVersion\RenameFiles\Win,myreadme.txt,,"My App Readme.txt"

The following example is an AddReg section that:

  • Deletes New Long Name.txt from the C:\Samples folder.

  • Deletes My Application Readme.txt from the Windows folder.

    Long Name.txt"
    HKLM,Software\Microsoft\Windows\CurrentVersion\DeleteFiles\Win,myreadme.txt,,"My App Readme.txt"

After these entries are renamed or deleted and processed, they are removed from the registry.

Note Note 

  • During the rename operation, the destination file is deleted before any files are renamed. If the same rename operation is queued twice, it could result in a loss of the file. For example, suppose there is a bitmap that needs to be renamed from Picture.bmp to "Really Cool 3D Picture.bmp." The second time such a rename operation is performed, "Really Cool 3D Picture.bmp" already exists, so it is deleted before the rename operation is performed. The exception to this rule is when the existing destination file name is a folder.

Setting Attributes for Files and Folders

To set the attributes for a file or folder, you use the same convention to create long file names using an optional flag.

For details, see the section on "Creating and deleting long file names."

Copying Files to the Program Files Folder

The following example copies three files to the Program Files\Accessories folder and creates links to one of the files:

CopyFiles = WordPadCopyFiles
UpdateInis = WordPadInis

WordPadCopyFiles = 24,%PROGRAMF%\%ACCESSOR%
setup.ini, progman.groups,, "group4=%APPS_DESC%" ;creates Accessories folder (if not already there)
setup.ini, group4,, """%WORDPAD_LINK%"",
""%24%\%PROGRAMF%\%ACCESSOR%\WORDPAD.EXE""" ;creates link in Accessories folder
APPS_DESC = "Accessories"
; Folder names - note that the short versions must match the truncated
; 8-character names for the long versions, or else there are problems.
PROGRAMF = "Progra~1" ; first 6 chars of Program_Files, + "~1"
ACCESSOR = "Access~1" ; first 6 chars of Accessories, + "~1"

Limitations of .inf Files

  • Directories cannot be deleted.

  • Files cannot be moved to a different location when using RenFiles. (The RenFiles command only renames a file in place.)

  • Copies of a file cannot be made. (The CopyFiles command only copies files from the source disk to the destination directory.)

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2015 Microsoft