开发者

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.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."

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:

  1. 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 for NoStartPage is REG_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.

  2. Set the System.AppUserModel.PreventPinning property on windows and shortcuts. This property must be set on a window before the PKEY_AppUserModel_ID property.

  3. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜