Jump to content

Using INF file to create shortcuts anywhere


Recommended Posts

Note: This post assumes that you have a working knowledge of INF files, the ProfileItems directive and DIRIDS.

Using the ProfileItems information documented on Microsoft's website you can only create shortcuts within the Start Menu folder structure. I have found a poorly documented technique which can be used to create shortcuts in any location using the ProfileItems directive. I haven't seen this documented anywhere and could only find a couple of examples of its usage through Google.

The undocumented feature I have uncovered is an additional name-attributes flag for the Name directive of the profile-items-section.

Syntax:

[profile-items-section]

Name=link-name[,name-attributes]

Undocumented flag:

0x00000008, dirid (FLG_PROFITEM_CSIDL)

Directs setup to create or delete a Start menu item in the location specified by dirid.

Use:

[profile-items-section]

Name=link-name, 0x00000008, dirid

Simply substitute the DIRID for the location you want the shortcut in. You can use the SUBDIR directive to place a shortcut into a sub-folder. Using the SUBDIR directive you can create a shortcut almost anywhere.

Here is an example of the above flag in use:

;Sample INF file to create a desktop shortcut to the SYSPREP.EXE file
[Version]
Signature=$CHICAGO$

[DefaultInstall]
ProfileItems=AUSysprepDesktopItemAdd

[AUSysprepDesktopItemAdd]
Name = "Prepare Computer for Imaging", 0x0000008, 16409
CmdLine = 24,"SYSPREP","sysprep.exe -mini -reseal -shutdown -quiet"
InfoTip = "Reseals computer before disk imaging"
WorkingDir = 24,"SYSPREP"

For anyone interested I use a similar technique to remove the shortcut from the desktop:

;Sample INF to remove desktop shortcut to the SYSPREP.EXE file.
[Version]
Signature=$CHICAGO$

[DefaultInstall]
DelFiles=AUSysprepDesktopItemDel

[DestinationDirs]
AUSysprepDesktopItemDel = 16409

[AUSysprepDesktopItemDel]
"Prepare Computer for Imaging.lnk"

Further Information:

INF ProfileItems Directive

http://msdn2.microsoft.com/en-us/library/ms794557.aspx

List of available DIRIDS:

http://www.msfn.org/board/index.php?showtopic=11440

Link to comment
Share on other sites


How come I've not read about this undocumented feature before?

As far as I can tell I'm the first to document this particular feature. Here's how I came across this feature:

I wanted to create a shortcut on the desktop but couldn't a way to do it using the ProfileItems directive. I read the documentation for ProfileItems on the MSDN site and decided to search for additional names-attributes flags. I came across it when I did a google search for FLG_PROFITEM_CURRENTUSER. Several of the results were to a file called "setupapi.h". Looking through the setupapi.h file I discovered an undocumented ProfileItems flag, FLG_PROFITEM_CSIDL (0x00000008).

I knew that the CSIDL values were used to identify special folders so I guessed that this flag could be used to set the location for creation of the shortcut. I still didn't know how to use the flag to set the shortcut location, however after a couple of google searches I found an example of this flag in use. Following these examples I was able to quickly determine how the flag worked and successfully created shortcuts in a variety of locations.

I decided to document this technique here to assist anyone else interested in using INF files to create shortcuts for their unattended installs.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...