{"id":1249,"date":"2017-12-04T05:51:41","date_gmt":"2017-12-04T05:51:41","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/?p=1249"},"modified":"2020-01-09T09:35:50","modified_gmt":"2020-01-09T09:35:50","slug":"quick-launch-shortcut-in-vista-and-windows-7","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/quick-launch-shortcut-in-vista-and-windows-7\/","title":{"rendered":"Quick Launch shortcut in Vista and Windows 7"},"content":{"rendered":"<p><strong>InstallerGeek created the topic: Quick Launch shortcut in Vista and Windows 7<\/strong><br \/>\nThe right substitute for Vista\/XP like Quick Launch shortcut is to make the link pinned to the taskbar (IMO).<br \/>\n><br \/>\n> It appears as simple as putting the shortcut in User Pinned\\TaskBar subfolder of Quick Launch folder in Windows 7.<br \/>\n><br \/>\n>      <!-- Quick Launch per-user folder --><br \/>\n>      <Directory Id=\"QL1\" SourceName=\"Application Data\"><br \/>\n>        <Directory Id=\"QL2\" Name=\"Microsoft\"><br \/>\n>          <Directory Id=\"QL3\" Name=\"Internet Explorer\"><br \/>\n>            <Directory Id=\"QL4\" Name=\"Quick Launch\" \/><br \/>\n>        <Directory Id=\"QL5\" Name=\"User Pinned\" \/><br \/>\n>                <Directory Id=\"QL6\" Name=\"TaskBar\" \/><br \/>\n>                <\/Directory><br \/>\n>              <\/Directory><br \/>\n>            <\/Directory><br \/>\n>        <\/Directory><br \/>\n><br \/>\n> Now, I can condition the installation of the component containing the Shortcut element.<br \/>\n> When OS is Windows 7 shortcut gets created in QL6 directory, otherwise in QL4.<br \/>\n><br \/>\n> Since this would unnecessarily create User Pinned\\TaskBar folders on Vista and XP, does anybody know if there is a more elegant way to accomplish the same goal?<\/p>\n<p><strong>applicationPackaging replied the topic: Re: Quick Launch shortcut in Vista and Windows 7<\/strong><br \/>\nTony, how do you catch the case, that your user only can install applications elevated as administrator (don&#8217;t assume everybody is admin on his\/her machine)? Wouldn&#8217;t the quick launch shortcut then only appear on the administrator&#8217;s quick launch bar and hence is invisible for the normal user(s)?<\/p>\n<p>Tom<\/p>\n<p><strong>applicationPackaging replied the topic: Re: Quick Launch shortcut in Vista and Windows 7<\/strong><br \/>\nBecause of various other factors, I require from users to have admin rights when installing and running the app. So this is not a problem for me (at least not for now).<\/p>\n<p>But you don&#8217;t have to be admin to install the application. Administrator can approve of certain MSI to be installed by non-elevated users on his network and MSI takes care of elevating the rights so that, for example, folders and files can be created in Program Files.<\/p>\n<p>I tested this scenario once: I allowed all users on my machine to run MSI and as non-elevated user I had no problem installing the app. I had problems running it because some of installed apps write to Program Files subfolders, but that&#8217;s another issue.<\/p>\n<p><strong>applicationPackaging replied the topic: Re: Quick Launch shortcut in Vista and Windows 7<\/strong><br \/>\nI am not sure if I understood the question well and if my previous response makes sense. But this is how would I try doing it if I had to do it and if WiX didn&#8217;t let me do declaratively:<\/p>\n<p>Even if MSI (or more correctly parts of install) run with elevated privileges, I think that immediate custom action runs non-elevated and I can find current user&#8217;s ApplicationData folder via Shell API call GetSpecialFolder. I can then create shortcut links programmatically in custom action code as seen below (I don&#8217;t know where I got it from, probably some MSDN article).<\/p>\n<p>\/\/<br \/>\n\/\/<br \/>\n\/\/ CreateLink &#8211; uses the Shell&#8217;s IShellLink and IPersistFile interfaces<br \/>\n\/\/              to create and store a shortcut to the specified object.<br \/>\n\/\/<br \/>\n\/\/ Returns the result of calling the member functions of the interfaces.<br \/>\n\/\/<br \/>\n\/\/ Parameters:<br \/>\n\/\/ lpszPathObj  &#8211; address of a buffer containing the path of the object.<br \/>\n\/\/ lpszPathLink &#8211; address of a buffer containing the path where the<br \/>\n\/\/                Shell link is to be stored.<br \/>\n\/\/ lpszDesc    &#8211; address of a buffer containing the description of the<br \/>\n\/\/                Shell link.<br \/>\n\/\/ lpszIconLink &#8211; address of a buffer containing the path where the<br \/>\n\/\/                Shell link icon can be found.<br \/>\n\/\/ index        &#8211; index of the icon<br \/>\n\/\/<\/p>\n<p>HRESULT CreateLink(LPCTSTR lpszPathObj, LPCTSTR lpszPathLink, LPCTSTR lpszDesc, LPCTSTR lpszIconLink, int index) {<br \/>\n    HRESULT hres;<br \/>\n    IShellLink* psl;<\/p>\n<p>    \/\/ Get a pointer to the IShellLink interface.<br \/>\n    hres=::CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,<br \/>\n                            IID_IShellLink, (LPVOID*)&#038;psl);<br \/>\n    if(SUCCEEDED(hres))<br \/>\n    {<br \/>\n        IPersistFile* ppf;<\/p>\n<p>        \/\/ Set the path to the shortcut target and add the description.<br \/>\n        psl->SetPath(lpszPathObj);<br \/>\n        psl->SetDescription(lpszDesc);<br \/>\n        if(lpszIconLink!=0)<br \/>\n            psl->SetIconLocation(lpszIconLink, index);<\/p>\n<p>        \/\/ Query IShellLink for the IPersistFile interface for saving the<br \/>\n        \/\/ shortcut in persistent storage.<br \/>\n        hres=psl->QueryInterface(IID_IPersistFile, (LPVOID*)&#038;ppf);<\/p>\n<p>        if(SUCCEEDED(hres))<br \/>\n        {<br \/>\n            USES_CONVERSION;<\/p>\n<p>            \/\/ Ensure that the string is Unicode.<br \/>\n            LPWSTR wsz=CT2W(lpszPathLink);<\/p>\n<p>            \/\/ Add code here to check return value from MultiByteWideChar<br \/>\n            \/\/ for success.<\/p>\n<p>            \/\/ Save the link by calling IPersistFile::Save.<br \/>\n            hres = ppf->Save(wsz, TRUE);<br \/>\n            ppf->Release();<br \/>\n        }<br \/>\n        psl->Release();<br \/>\n    }<br \/>\n    return hres;<br \/>\n}<br \/>\n<strong>InstallerGeek replied the topic: Re: Quick Launch shortcut in Vista and Windows 7<\/strong><br \/>\nThere&#8217;s no need to do that: The Shortcut table can be used to create shortcuts in any directory. And it takes care of uninstall and rollback, which your code does not.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>InstallerGeek created the topic: Quick Launch shortcut in Vista and Windows 7 The right substitute for Vista\/XP like Quick Launch shortcut is to make the link pinned to the taskbar&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[49],"tags":[303,304],"class_list":["post-1249","post","type-post","status-publish","format-standard","hentry","category-general","tag-vista","tag-windows-7"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/1249","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=1249"}],"version-history":[{"count":1,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/1249\/revisions"}],"predecessor-version":[{"id":1250,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/1249\/revisions\/1250"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=1249"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=1249"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=1249"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}