Removing exe from windows startmenu quick launch
For work we have two shortcuts that get installed to the start menu with both of them pointing to the same exe (but the second with different command line arguments).
Some times windows will pick the second shortcut to display in the start menu hot program list which is bad because it causes a full update of the application.
Is there a开发者_开发问答 way to tell windows not to show that shortcut in the start menu list?
Yes, in fact Raymond Chen just wrote about this:
You can set the
System.AppUserModel.ExcludeFromShowInNewInstall
property toVARIANT_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."
Sample code (CCoInitialize
class):
#include <windows.h>
#include <tchar.h>
#include <shlobj.h>
#include <atlbase.h>
// class 3CCoInitialize 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;
}
You'll find the documentation for those settings here: Application User Model IDs (AppUserModelIDs). Specifically, you're looking for the section entitled "Exclusion Lists for Taskbar Pinning and Recent/Frequent Lists". The applicable portion is reprinted below:
Applications, processes, and windows can choose to make themselves unavailable for pinning to the taskbar or for inclusion in the Start menu's MFU list. There are three mechanisms to accomplish this:
Add the
NoStartPage
entry to the application's registration as shown here:HKEY_CLASSES_ROOT\Applications\Example.exe\NoStartPage
The data associated with the
NoStartPage
entry is ignored. Only the presence of the entry is required. Therefore, the ideal type forNoStartPage
isREG_NONE
.Note that any use of an explicit AppUserModelID overrides the
NoStartPage
entry. If an explicit AppUserModelID is applied to a shortcut, process, or window, it becomes pinnable and eligible for the Start menu MFU list.Set the
System.AppUserModel.PreventPinning
property on windows and shortcuts. This property must be set on a window before thePKEY_AppUserModel_ID
property.Add an explicit
AppUserModelID
as a value under the following registry subkey as shown here:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Explorer\FileAssociation\NoStartPageAppUserModelIDs\AppUserModelID
Each entry is a
REG_NULL
value with the name of the AppUserModelID. Any AppUserModelID found in this list is not pinnable and not eligible for inclusion in the Start menu MFU list.
精彩评论