banner graphic
Reference

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 are:

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 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.

[progman.groups]
folder_1=Folder_1_Name
folder_2=Folder_2_Name
:
folder_n=Folder_n_Name

[folder_1]
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.

Notes

Example: Games

[Optional Components]
games

[games]
OptionDesc= %GAMES_DESC%
CopyFiles= wingames.files
UpdateInis= wingames.links
[wingames.files]
cards.dll
freecell.exe
freecell.hlp
mshearts.exe
mshearts.hlp
sol.exe
sol.hlp
winmine.exe
winmine.hlp

[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" will appear in the Optional Components dialog box in Setup, and if selected, a Games folder will be created in the Program Files folder with links to Solitaire, Minesweeper, Hearts, and FreeCell.

Creating and deleting long file names

The setup engine in Windows 32-bit versions of the browser is a 16-bit .dll file for backwards compatibility. Because of this, the Windows setup engine can only copy files with 8.3 file names. In order to create and delete files with long file names, the setup engine runs a 32-bit application when it exits that renames any 8.3 file names to long file names and deletes files with long file names. The 32-bit application gets its instructions from preĀ­defined keys in the registry.

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

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RenameFiles

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

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\DeleteFiles

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.

1 READONLY
2 HIDDEN
3 SYSTEM

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\System\Sample folder:

HKLM,Software\Microsoft\Windows\CurrentVersion\RenameFiles\Sys,,,%11% HKLM,Software\Microsoft\Windows\CurrentVersion\RenameFiles\Sys,SAMPLE,,"SAMPLE,6"

Note

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:

[MyAppShort2Long]
HKLM,Software\Microsoft\Windows\CurrentVersion\RenameFiles\Samples,,,C:\Samples
HKLM,Software\Microsoft\Windows\CurrentVersion\RenameFiles\Samples,oldname.txt,,"New Long Name.txt"
HKLM,Software\Microsoft\Windows\CurrentVersion\RenameFiles\Win,,,%25%
HKLM,Software\Microsoft\Windows\CurrentVersion\RenameFiles\Win,myreadme.txt,,"My App Readme.txt"

The following example is an AddReg section that:

[MyAppDelLong]
HKLM,Software\Microsoft\Windows\CurrentVersion\DeleteFiles\Samples,,,C:\Samples
HKLM,Software\Microsoft\Windows\CurrentVersion\DeleteFiles\Samples,oldname.txt,,"New Long Name.txt"

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

After these renames and deletions have been processed, the entries are removed from the registry.

Note

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

Because copying Windows files is a 16-bit operation, only short (8.3) file names can be used. To access the Program Files folder, you will need to use the 8.3 equivalent, "24,PROGRA`1", in the [DestinationDirs] section (LDID 24 is the root of the drive that contains the Windows folder). Similarly, the short file name equivalent must be used to access any folders with long file names that are within the Program Files folder.

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

[WordPadInstall]
CopyFiles = WordPadCopyFiles
UpdateInis = WordPadInis

[DestinationDirs]
WordPadCopyFiles = 24,%PROGRAMF%\%ACCESSOR%

[WordPadCopyFiles]
mswd6_32.wpc
wordpad.exe
write32.wpc

[WordPadInis]
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

[Strings]
APPS_DESC = "Accessories"
WORDPAD_LINK = "WordPad"
; Folder names - note that the short versions must match the truncated
; 8-character names for the long versions, or else there will be problems.
PROGRAMF = "Progra~1" ; first 6 chars of Program_Files, + "~1"
ACCESSOR = "Access~1" ; first 6 chars of Accessories, + "~1"

Limitations of .inf files