12

I'm in Windows 7 working on combining two apps with the same task bar icon, as described in this question:

Pinning advertised shortcuts on the taskbar in windows 7

I see there, and it lots of online documentation that I need to set the AppUserModelID as a property of the shortcut. My installer program uses the basic Visual Studio 2008 setup project, and I don't see any way to set shortcut properties on installation. Is there any head-start anyone can give me on how to do this?

Community
  • 1
  • 1
Clyde
  • 8,017
  • 11
  • 56
  • 87

3 Answers3

8

Sheng commented that "You can also switch to other MSI authoring tools that supports setting the appid for shortcuts, such as WIX or NSIS."

To achieve this using a Shortcut element in Wix you must add a child ShortcutProperty element to your Shortcut element and use the Shell property name "System.AppUserModel.ID" as the key.

    <Shortcut Id="StartMenuShortcut"
              Name="Shortcut Name"
              Description="Shortcut Description"
              Target="[INSTALLLOCATION]Application.exe"
              WorkingDirectory="INSTALLLOCATION">
      <ShortcutProperty Key="System.AppUserModel.ID" Value="AppUserModelID" />
    </Shortcut>
Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
Olly
  • 5,966
  • 31
  • 60
  • 4
    There are known issues with explicitly setting the ShortcutProperty/Key to "System.AppUserModel.ID" - http://support.microsoft.com/en-us/kb/2745126. It looks as though Microsoft recommends that the GUID+PropertyID be used instead. "System.AppUserModel.ID" = "{9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}, 5" (from - https://msdn.microsoft.com/en-us/library/windows/desktop/dd391569%28v=vs.85%29.aspx) – jbudreau Apr 03 '15 at 13:43
  • Thanks @jbudreau, that worked in the Keybase installer, and will soon ship in an upcoming version: https://github.com/keybase/client/pull/11185 It bears repeating that the OP asked about Windows 7, which will have errors explicitly specifying shortcut properties by name instead of GUID, according the the above MS links – Steve Apr 03 '18 at 18:45
2

I don't know anything about VS2k8 setup projects so I don't know if you can run custom actions etc but I do know that to set the AppId on a shortcut you load/create your shortcut and query its IShellLink for IPropertyStore, then InitPropVariantFromString a variant with your id and call SetValue(PKEY_AppUserModel_ID,propvariant) + Commit on the propertystore

Anders
  • 97,548
  • 12
  • 110
  • 164
1

Adding to Ander's reply.

Visual Studio Setup project does not support setting appid and will probably never be unless Microsoft reverse the deprecation of Setup project feature.

There is a Windows API Code Pack that helps in invoking shell APIs. Here is a tutorial on creating shortcut in custom action. You can add the code to update the shortcut to the custom action.

You can also switch to other MSI authoring tools that supports setting the appid for shortcuts, such as WIX or NSIS.

Sheng Jiang 蒋晟
  • 15,125
  • 2
  • 28
  • 46
  • 3
    By the way, emoacht has a great blog post describing how you create a shortcut with an associated AppUserModelID in C# (http://emoacht.wordpress.com/2012/11/14/csharp-appusermodelid/) – Pierre Arnaud Jul 29 '13 at 06:56