Creating shortcuts using INF files

By Daniel U. Thibault

 

Some additions to Walter Zackery's bit about creating shortcuts using .INF files and RunDLL from a BAT:

Within an INF, you can use this:

[AddLink]
setup.ini, progman.groups,, "group1=""%ShortcutLocation%"""
setup.ini, group1,,"""%ShortcutDesc%"",""%28710%\Wordpad.exe"",,,,,""Wordpad.exe"""

"group1" is an arbitrary place-holder group name.
The %ShortcutLocation% string can be a long file name if it is quoted (like in my example).
It is relative to Start Menu\Programs unless fully qualified.
To put a shortcut in the SendTo folder, for example, I would specify:

setup.ini, progman.groups,,"group1=""%10%\SendTo"""

The %10% place-holder is peculiar to INF and retrieves the Windows directory path (in most cases C:\Windows).
%24% is the Applications (Program Files) directory root (typically C:\).
The entire %24%\Progra~1\Access~1\ path can be retrieved as %28710% under Win 98 and later.
%11% is the System directory (System32 under Win NT), %17% is the INF directory.

In generating the shortcut itself, the quoted argument to "setup.ini, group1,," is:

"<LinkTitle>,<Target>,<Icon_file>,<Icon_index>,<Profile>,<Start In>,<Description>"

<LinkTitle> is the shortcut's descriptive title.
<Target> is the fully qualified path to the target, including command-line switches and arguments;
note that if the <Target> is quoted, it'll be expanded from SFN to LFN automatically.
<Icon_file> is the fully qualified path to the icon-holding resource (an EXE, DLL, ICO, ICL or some such)
<Icon_index> is the zero-based index of the icon in <Icon_file>.
<Profile> when specified, creates the link for that user profile only.
<Start In> is the current-path setting for the shortcut.
<Description> is an undocumented optional argument; you can safely omit it or set it to the target's title.
The Microsoft INFs label it "details view".
Note: When specifying the Icon_index, if you know the icon's Resource ID (using MicroAngelo's Librarian, Colin WIlson's PE Module Explorer or ResHacker, for example), you can specify it instead of the zero-based index by turning it into a negative number.
For example, Microsoft Excel 8's spreadsheet icon is the second one in Excel.exe -- and thus its Icon_index is "1". Its Resource ID is 258, so you can alternately refer to it as "-258".

Example:

setup.ini, group1,,"""Link to Wordpad"",""%24%\Progra~1\Access~1\Wordpad.exe"",""%11%\Cool.dll"",3,,%17%"

To delete a shortcut, the quoted argument must consist of just the shortcut description.
Like so:

setup.ini, group1,,"""%ShortcutDesc%"""

 

Daniel U. Thibault
a.k.a. Urhixidur
a.k.a. Seigneur Bohémond de Nicée
ICQ: 4985610
AIM: Urhixidur
URL: www.bigfoot.com/~D.U.Thibault


page last uploaded: 19 December 2012, 12:11