How do specify that a shortcut should not be promoted as newly-installed on the Start menu?


Windows XP employed a number of heuristics to determine which Start menu shortcuts should be promoted when an application is newly-installed. But what if those heuristics end up guessing wrong?

You can set the System.App­User­Model.Exclude­From­Show­In­New­Install property to VARIANT_TRUE to tell the Start menu, “I am not the primary entry point for the program; I’m a secondary shortcut, like a help file.”

#include <windows.h>
#include <tchar.h>
#include <shlobj.h>
#include <atlbase.h>

// class CCoInitialize incorporated here by reference

int __cdecl _tmain(int argc, TCHAR **argv)
{
 // error checking elided for expository purposes
 CCoInitialize init;
 CComPtr<IShellLink> spsl;
 spsl.CoCreateInstance(CLSID_ShellLink);
 spsl->SetPath(TEXT("C:\\Program Files\\LitWare\\LWUpdate.exe"));
 PROPVARIANT pvar;
 pvar.vt = VT_BOOL;
 pvar.boolVal = VARIANT_TRUE;
 CComQIPtr<IPropertyStore>(spsl)->SetValue(PKEY_AppUserModel_ExcludeFromShowInNewInstall, pvar);
 CComQIPtr<IPersistFile>(spsl)->Save(L"LitWare Update.lnk", TRUE);
 return 0;
}
Comments (32)
  1. Jim says:

    Or even better, you could not add your stupid "secondary shortcut" to the start menu in the first place!  Particularly annoying is when an installer creates a folder just to put shortcuts to the readme, uninstaller and actual program.  Just putting the one useful shortcut directly under the start menu would be much better!

    (OK there are exceptions e.g. MS Office tools submenu.  But 90% of the time it's an uninstaller, which is better accessed through add/remove programs.)

    Nevertheless, thanks for the interesting article :-)

  2. Henke37 says:

    It's a subfeature that had to compete with such features as "give my application a special color, because I am special".

  3. WesW says:

    Raymond,

    What would be your suggestion on how to do this from a MSI? That is, maybe the MSI installs three shortcuts, but we only want one of them be "promoted"?

  4. Christopher Allen-Poole says:

    Even though I use Launchy and so never open the start menu on XP anymore (and on Win. 7, I use Start Menu's search functions) I'm going to go ahead and agree with Jim.  Most of the shortcuts which are added to the Start Menu are irrelevant to my life.  Heck, I was able to find 10 useless items in the first three folders I examined.

    The worst, though, are the links to websites.  I don't want a link to your website in my shortcut bar.  If I want to get to your site, I will do a web search for it or I will look for the URL in your "about" section.  Frankly, the belief that I will even think "these people will clearly have a link in the start menu," is foolish at best.

  5. Joshua says:

    Ref: Christopher's comment.

    I'm glad Windows shell replacements are alive and well.

  6. Anonymous says:

    > But 90% of the time it's an uninstaller, which is better accessed through add/remove programs.)

    I definetely prefer uninstallers in start menu. Add/remove takes AGES to open.

  7. Troll says:

    I prefer uninstallers in the Start menu for the same reason. Add/remove still takes ages to open. I disliked how Vista guidelines recommended that programs put just their main EXE link in the Start menu. yet

  8. Alex Grigoriev says:

    Add/Remove takes ages to open, because of a feature ("somebody got a bonus for") that it's trying to estimate the disk space the program is taking. If the installation doesn't give an explicit figure (and I don't know if there is a way to do that), that dialog just reads the directory and adds up sizes of all files. It also tries to find out when the feature was run the last time (who cares???), supposedly by using LastAccessed timestamp, which is not updated anymore.

    How it finds out which directory to calculate is another matter, as I don't see there is a way to tell it. One my InstallShield-generated installations just made it think that the feature takes the whole Program Files and showed a few gigabytes. Took forever for the dialog to open.

    One day the whole Add/Remove dialog needs to be reworked. There should be a way to group the items by vendor and other attributes. Though I'm grateful the updates don't show up in it anymore.

    [You might want to read my Windows Confidential column for February 2011 when it comes out. -Raymond]
  9. Adam Rosenfield says:

    @Anonymous, @Troll:

    I don't think that uninstallers should be in the start menu because they're not a program that you typically run.  Uninstalling is an infrequent event, so uninstallers should avoid cluttering up the start menu.  If I choose to uninstall something, I feel perfectly fine navigating to the program's installation folder in Explorer and running its uninstaller from there, which I prefer doing to using Add/Remove Programs because the latter is so slow to open.

    And as Raymond said, removing the uninstaller from the start menu also prevents people from going "Oooh, look at the shiny executable!" and accidentally uninstalling the program they just installed.  Granted that's probably a narrow use case, but you might as well protect those people from themselves if you can.  (Then again, those people's computers are probably infested with virii and spyware because they like looking at dancing bunnies).

  10. Kemp says:

    Having recently started using Windows 7, I have to say that add/remove is far quicker opening now. At least, it shows the applications it has already calculated rather than waiting for all of them like XP did.

  11. Ryan says:

    "The Legend of Uninstall" that Raymond was referring to is available now:

    technet.microsoft.com/…/gg558108.aspx

  12. sukru says:

    @Ryan I've just read the article, thanks for the link.

    It seems like Windows 7 is doing it almost right. It still has to search (I think for icons this time), however is much faster on the second startup (only 1 second).

    Still half of the list is filled with Visual Studio and Office packages and their extensions. I wish we had a way to group those. (I got -100 points for this, right?)

  13. Michael Urman says:

    @WesW: See the MsiShortcutProperty table ( msdn.microsoft.com/…/dd408039(v=vs.85).aspx ).

  14. kinokijuf says:

    @sukru: most of them are redistributables or shared components.

  15. Paul M. Parks says:

    In addition to Adam Rosenfield's comments, I'd add that uninstalling a program is something the average user would do a lot less frequently than running a program. I also think that appwiz.cpl is slower than I'd prefer it to be, but I use it so infrequently that I really don't care.

  16. Joshua says:

    I'd rather the uninstaller be in the start menu than nowhere. In Win 3.1 they went in the program group, which was the start menu folder equivalent.

  17. Alex Grigoriev says:

    [You might want to read my Windows Confidential column for February 2011 when it comes out. -Raymond]

    OK. That was pretty interesting. Actually, I have Windows 7 at home, though most of my day hours are still spent with XP. My remaining gripe is its inability to group by the vendor.

    [Another reason to upgrade to Windows 7, right? -Raymond]
  18. WndSks says:

    Ahh, finally I can make this comment and be (somewhat) on topic: Where the hell is the documentation for the uninstall registry key and values? If I google or bing "NoModify" "DisplayIcon" site:msdn.microsoft.com I only get social stuff and msdn.microsoft.com/…/aa372105%28VS.85%29.aspx but it is MSI specific.

    AFAIK there is no page on MSDN that documents DisplayIcon etc for non-msi installers!

    If you really look around (took me several hours) you will find msdn.microsoft.com/…/ms954376 it is for Win2000 and does document Publisher,VersionMajor,VersionMinor and InstallLocation, and msdn.microsoft.com/…/aa741201%28v=vs.85%29.aspx has info about AuthorizedCDFPrefix.

    UninstallString and DisplayName had documentation back in the Win95 days, you can still find some of it, google win32.hlp

    SystemComponent is for windows.

    WindowsInstaller, Size, Version and Language might be MSI specific, I don't know.

    That just leaves DisplayIcon, DisplayVersion, Readme, Comments, Contact, HelpLink, HelpTelephone, URLInfoAbout, URLUpdateInfo, QuietUninstallString, ModifyPath, InstallDate, NoModify, NoRepair, NoRemove, RequiresIESysFile and EstimatedSize! I'm not asking for much, just a page with the REG_* type, minimum OS version and a basic description of what it does…

    [I wonder if people do that to radio talk shows, too. "Hi, I was waiting for you to have somebody on the show to talk about the situation in Egypt, because I've had this question about King Tut and finally I can ask it and be (somewhat) on topic." I wonder how many other people have "something I've always wanted to complain about" topics in their back pocket, just waiting for me to mention something tangentially related so they can let loose. (Some people don't bother waiting.) -Raymond]
  19. Joshua says:

    @WndSks: read the NSIS documentation. That's where I got the information from when I needed it. Minimum version on most of those is WinXP.

  20. WndSks says:

    @Joshua: The NSIS wiki is wrong, most of those values work on Win2000, that is when appwiz.cpl was updated from the Win95 look

    The official NSIS docs about the uninstall info is @ nsis.sourceforge.net/…/AppendixD.html

    I bet you are talking about nsis.sourceforge.net/…/Remove_Programs , that is a wiki page and can be edit by anyone (Sourceforge is still having problems, I can't log in on the wiki to fix it)

  21. Skyborne says:

    I'm not sure how that so-called feature ever beat its minus 100 points.  Aside from the obvious programming of the heuristics and the overrides, there's the never-implemented "Caring has not been, is simply not, nor will ever be a part of this user's repertoire" button to make it *shut up*.

    [This earned its 100 points because without it, users were roaching their systems. As noted in the linked article, there is a class of users who feel that they need to run any program highlighted in yellow "because the computer told me to." (You also don't want the Start menu picking "Contoso Organizer (safe mode)" instead of the main Contoso shortcut.) -Raymond]
  22. WndSks says:

    @Raymond: It's not like my comment was the first about ARP, you already talked about your Technet ARP article in a comment, I thought a little more ARP discussion would not be a problem, guess I was wrong. But would it hurt you to actually link to the documentation or just admit that it does not exist?

    [I don't have a link to the documentation (if it exists), but I can't say "it doesn't exist" because that would be proving a negative. It might be in a KB article somewhere. (I referred to my TechNet article in an attempt to shut down the digression, not to encourage it.) -Raymond]
  23. WndSks says:

    I made a little table, probably incomplete and with incorrect info but it is better than nothing; windowssucks.wordpress.com/win-registry-uninstall-values

  24. Troll says:

    Well compared to XP, Windows 7/Vista do load Add/Remove considerably faster. I do need and value certain info it shows like Last Run time, Directory path and size. @Adam Rosenfield, with most apps these days using the venerable Windows Installer, the uninstaller is now mostly in %windir%Installer with a cryptic file name so Start menu uninstall links are your only hope for quick uninstallation. I hope MS doesn't throw away all the info the ARP shows in a future Windows version to speed up loading app names.

  25. Worf says:

    I have to disagree, honestly. I don't mind the extra shortcuts at all, because they are handy. Uninstall from start is hugely helpful if an app needs constant reinstallation, or if you're QA'ing your app and have to uninstall/reinstall daily. Or beta test.

    And normal users like having help there as well.

    As for every techie here that hates them – fix your own damn start menu! You of all people ought to not only remove the (to you) unnecessary icons, while everyone else can have easy to open help and other stuff and try to avoid support calls.

  26. googly says:

    For those of you still running 2000 or XP (I think it also works on 2003), use this Add/Remove Programs alternative called Safarp: wistinga.online.fr/safarp

    I have no beef with the Programs and Features dialog in Windows 7, it populates very fast indeed.

  27. easy solvable says:

    Why can't a background thread get the details (size, last used, …)? And if it should be, but isn't, obvious to the user that there's a background thread, a solution would be a simple status bar with "getting additional info…", that would be sufficient.

    [That works great as long as (1) the user didn't sort by size, last used, etc, and (2) you don't have to filter the items before presenting them. Perhaps you forget that the original Add/Remove Programs control panel with the details information was written in HTML. HTML doesn't have background threads. -Raymond]
  28. Nick says:

    [Another reason to upgrade to Windows 7, right? -Raymond]

    It's definitely a nice feature, but I was somewhat surprised by the way the Programs and Features panel works in Windows 7.  When you open it the panel starts filling with applications, but remains responsive to user interaction.  It's kind of nice, I suppose, that the UI doesn't lock up during loading.

    Unfortunately it also is just *asking* for trouble.  Trying to click on a specific program as it appears, but is then shuffled down the list as items earlier up are inserted means a lot of mistaken selections.  If the user isn't paying close attention to what was actually selected (as it scrolls down the list and out of view), they can easily click Uninstall for the wrong element.  If they've also previously selected the "Don't ask for confirmation" box then a program (which they don't even know the name of) can be quickly and silently uninstalled.  I was surprised that checking that box means many installers don't ask ANY questions. You click Uninstall and boom, it's gone (maybe that shouldn't be a surprise, but I'm used to step-after-step uninstallers).

    Anyway, I always thought that these kinds of interactive-while-populating tools were shunned by Microsoft because of their unfriendly and mistake-heavy nature, and was surprised to see it make a prominent appearance in Windows 7.

    [I suspect they came back because people complained that the folders too too long to populate. "Apparently the geniuses are Microsoft are too stupid to know how to fill a list box incrementally." (I like how this guy says that "Any idiot knows that the solution is to make the file system a relational database.") -Raymond]
  29. 640k says:

    "Any idiot knows that the solution is to make the file system a relational database."

    WinFS ;)

    [I was hoping I wouldn't need to explain the joke. -Raymond]
  30. Cheong says:

    For uninstallers issue, I wonder why the Windows Installer engine don't calculate the folder size when using installer APIs to do copying works. (Alright it could be an installer program, but even so just having MSI case handled would be a lot better)

    For those additional data files etc. created when the application runs, since uninstallers usually prefer to left them behind, it usually doesn't matter at all. (In lots of applications I've used, even if they offer "Clean All" option, in the end they left lots of log files in the folder)

    Now I have a remotely related idea when I'm typing this… Is there a way to programatically determine what folder in "Program Data" ("Program Files" is a lot more complicated I think, especially consider all the 3rd party plugins involved, so let's just limit it to "Program Data") is NOT tied to an installed application? That sounds like a nice feature for "disk cleanup" utility to have.

  31. Gabe says:

    In all fairness, Raymond, I think the guy on mcse.ms was complaining about apps that store 10s of thousands of files in a single directory rather than using a hierarchy of directories or a database.

    The way I read your comment, it sounds like you're saying that he thinks MS should have implemented NTFS as a database (which they did). That's very different from how I interpret it, which is "Any idiot knows you design your app to use subdirectories or a database, not store 50,000 files in a single directory".

    [I stand corrected. -Raymond]
  32. Cheong says:

    Indeed, I also get the implied "If you were to store lots of files in lots of directory, perheps you should store the filename/path mapping in database to avoid the recursive directory search cost.". That's why he use "and/or" instead of just "or".

Comments are closed.