{"id":5083,"date":"2013-03-04T07:00:00","date_gmt":"2013-03-04T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2013\/03\/04\/marking-a-shortcut-to-say-that-it-should-not-be-placed-on-the-windows-8-start-page-upon-installation-or-treated-as-a-newly-installed-application\/"},"modified":"2013-03-04T07:00:00","modified_gmt":"2013-03-04T07:00:00","slug":"marking-a-shortcut-to-say-that-it-should-not-be-placed-on-the-windows-8-start-page-upon-installation-or-treated-as-a-newly-installed-application","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20130304-00\/?p=5083","title":{"rendered":"Marking a shortcut to say that it should not be placed on the Windows 8 Start page upon installation or treated as a newly-installed application"},"content":{"rendered":"<p><P>\nToday&#8217;s Little Program creates a shortcut on the Start menu\nbut marks it as &#8220;Do not put me on the front page upon installation.&#8221;\nThis is something you should do to any secondary shortcuts\nyour installer creates.\nAnd while you&#8217;re at it, you may as well set the\n&#8220;Don&#8217;t highlight me as a newly-installed\nprogram&#8221; attribute used by Windows&nbsp;7.\n(Remember, Little Programs do little to no error checking.)\n<\/P>\n<PRE>\n#define UNICODE\n#define _UNICODE\n#define STRICT\n#include &lt;windows.h&gt;\n#include &lt;shlobj.h&gt;\n#include &lt;atlbase.h&gt;\n#include &lt;propkey.h&gt;\n#include &lt;shlwapi.h&gt;<\/p>\n<p>int __cdecl wmain(int, wchar_t **)\n{\n <A HREF=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2004\/05\/20\/135841.aspx\">CCoInitialize<\/A> init;<\/p>\n<p> CComPtr&lt;IShellLink&gt; spsl;\n spsl.CoCreateInstance(CLSID_ShellLink);<\/p>\n<p> wchar_t szSelf[MAX_PATH];\n GetModuleFileName(GetModuleHandle(nullptr), szSelf, ARRAYSIZE(szSelf));\n spsl-&gt;SetPath(szSelf);<\/p>\n<p> PROPVARIANT pvar;\n CComQIPtr&lt;IPropertyStore&gt; spps(spsl);<\/p>\n<p> pvar.vt = VT_UI4;\n pvar.ulVal = APPUSERMODEL_STARTPINOPTION_NOPINONINSTALL;\n spps-&gt;SetValue(PKEY_AppUserModel_StartPinOption, pvar);<\/p>\n<p> pvar.vt = VT_BOOL;\n pvar.boolVal = <A HREF=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2004\/12\/22\/329884.aspx\">VARIANT_TRUE<\/A>;\n CComQIPtr&lt;IPropertyStore&gt; spps(spsl);\n spps-&gt;SetValue(PKEY_AppUserModel_ExcludeFromShowInNewInstall, pvar);<\/p>\n<p> spps-&gt;Commit();<\/p>\n<p> wchar_t szPath[MAX_PATH];\n SHGetSpecialFolderPath(nullptr, szPath, CSIDL_PROGRAMS, FALSE);\n PathAppend(szPath, L&#8221;Awesome.lnk&#8221;);\n CComQIPtr&lt;IPersistFile&gt;(spsl)-&gt;Save(szPath, FALSE);<\/p>\n<p> return 0;\n}\n<\/PRE>\n<P>\nFirst, we create a shell link object.\n<\/P>\n<P>\nNext, we tell the shell link that its target is the currently-running\nprogram.\n<\/P>\n<P>\nNow the fun begins.\nWe get the property store of the shortcut and set two new properties.\n<\/P>\n<UL>\n<LI>\n    Set\n    <A HREF=\"http:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/jj553605(v=vs.85).aspx\">\n    System.App&shy;User&shy;Model.Start&shy;Pin&shy;Option<\/A>\n    to\n    <CODE>APP&shy;USER&shy;MODEL_START&shy;PIN&shy;OPTION_NO&shy;PIN&shy;ON&shy;INSTALL<\/CODE>.\n    This prevents the shortcut from defaulting to the Windows&nbsp;8\n    Start page.\n<LI>\n    Set\n    <A HREF=\"http:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/dd391568(v=vs.85).aspx\">\n    System.App&shy;User&shy;Model.Exclude&shy;From&shy;Show&shy;In&shy;New&shy;Install<\/A>\n    to <CODE>VARIANT_TRUE<\/CODE>.\n    This prevents the shortcut from being highlighted as a new application\n    on the Windows&nbsp;7 Start menu.\n<\/UL>\n<P>\nWe then commit those properties back into the shortcut.\n<\/P>\n<P>\nFinally, we save the shortcut.\n<\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today&#8217;s Little Program creates a shortcut on the Start menu but marks it as &#8220;Do not put me on the front page upon installation.&#8221; This is something you should do to any secondary shortcuts your installer creates. And while you&#8217;re at it, you may as well set the &#8220;Don&#8217;t highlight me as a newly-installed program&#8221; [&hellip;]<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-5083","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>Today&#8217;s Little Program creates a shortcut on the Start menu but marks it as &#8220;Do not put me on the front page upon installation.&#8221; This is something you should do to any secondary shortcuts your installer creates. And while you&#8217;re at it, you may as well set the &#8220;Don&#8217;t highlight me as a newly-installed program&#8221; [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/5083","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=5083"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/5083\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=5083"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=5083"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=5083"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}