{"id":69043,"date":"2005-09-01T15:50:00","date_gmt":"2005-09-01T15:50:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2005\/09\/01\/how-can-i-add-a-shortcut-to-the-quick-launch-tray\/"},"modified":"2005-09-01T15:50:00","modified_gmt":"2005-09-01T15:50:00","slug":"how-can-i-add-a-shortcut-to-the-quick-launch-tray","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/how-can-i-add-a-shortcut-to-the-quick-launch-tray\/","title":{"rendered":"How Can I Add a Shortcut to the Quick Launch Tray?"},"content":{"rendered":"<p><IMG class=\"nearGraphic\" title=\"Hey, Scripting Guy! Question\" border=\"0\" alt=\"Hey, Scripting Guy! Question\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" width=\"34\" height=\"34\"> \n<P>Hey, Scripting Guy! How can I add a shortcut to the Quick Launch tray?<BR><BR>&#8212; ZR<\/P><IMG border=\"0\" alt=\"Spacer\" src=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/05\/spacer.gif\" width=\"5\" height=\"5\"><IMG class=\"nearGraphic\" title=\"Hey, Scripting Guy! Answer\" border=\"0\" alt=\"Hey, Scripting Guy! Answer\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" width=\"34\" height=\"34\"><A href=\"http:\/\/go.microsoft.com\/fwlink\/?linkid=68779&amp;clcid=0x409\"><IMG class=\"farGraphic\" title=\"Script Center\" border=\"0\" alt=\"Script Center\" align=\"right\" src=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/ad.jpg\" width=\"120\" height=\"288\"><\/A> \n<P>Hey, ZR. Before we answer this question we need to first answer a <I>different<\/I> question. And here\u2019s the answer: Frank \u201cHome Run\u201d Baker, who led the major league in homers four times, even though he never hit more than a dozen home runs in a single season.<\/P>\n<P>Oh, wait; wrong question. <I>Here\u2019s<\/I> the answer: no, unfortunately there\u2019s really no way to enable and disable the Quick Launch tray using a script. There <I>are<\/I> some workarounds floating around the Internet that use the SendKeys commands, but SendKeys is a bit \u2026 flaky \u2026 (to say the least) so we don\u2019t really recommend it. But if you search for <B>Quick Launch<\/B> and <B>SendKeys<\/B> you should be able to find a sample without any problem.<\/P>\n<P>Assuming that the Quick Launch tray is already enabled, however, it\u2019s pretty easy to add a new shortcut. This script, for example, adds Notepad.exe to the Quick Launch tray:<\/P><PRE class=\"codeSample\">Set objShell = CreateObject(&#8220;WScript.Shell&#8221;)\nSet colEnvironmentVariables = objShell.Environment(&#8220;Volatile&#8221;)<\/p>\n<p>strFolder = colEnvironmentVariables.Item(&#8220;APPDATA&#8221;) &amp; _\n &#8220;\\Microsoft\\Internet Explorer\\Quick Launch&#8221;<\/p>\n<p>Set objShortCut = objShell.CreateShortcut(strFolder &amp; _\n &#8220;\\Notepad.lnk&#8221;)\nobjShortCut.TargetPath = &#8220;Notepad.exe&#8221;\nobjShortCut.Description = &#8220;Open Notepad&#8221;\nobjShortCut.HotKey = &#8220;Ctrl+Shift+N&#8221;\nobjShortCut.Save\n<\/PRE>\n<P>This script actually accomplishes two tasks. First, it determines the location of the Quick Launch folder for the logged-in user. (We should point out that this script must be run on the local computer. That\u2019s because it relies on Windows Script Host to actually create the shortcut; without yet <I>another<\/I> set of workarounds WSH can\u2019t be used against remote computers). To get the path to the Quick Launch folder we create an instance of the <B>WScript.Shell<\/B> object and then use this line of code to retrieve a collection of environment variables:<\/P><PRE class=\"codeSample\">Set colEnvironmentVariables = objShell.Environment(&#8220;Volatile&#8221;)\n<\/PRE>\n<P>As it turns out, there\u2019s an environment variable named AppData that pinpoints the location of the Application Data folder. (If you don\u2019t believe us, type <B>echo %appdata%<\/B> at the command prompt and see what happens.) Application Data is the \u201chost\u201d folder for the Quick Launch folder; the path to the Quick Launch folder will always be the path to the Application Data folder plus <B>\\Microsoft\\Internet Explorer\\Quick Launch<\/B>. In other words, suppose this is the path to the Application Data folder:<\/P><PRE class=\"codeSample\">C:\\Documents and Settings\\kenmyer\\Application Data\n<\/PRE>\n<P>In that case, <I>this<\/I> will be the path to the Quick Launch folder:<\/P><PRE class=\"codeSample\">C:\\Documents and Settings\\kenmyer\\Application Data\\Microsoft\\Internet Explorer\\Quick Launch\n<\/PRE>\n<P>In turn, that means we can use this code (which combines the value of the AppData environment variable with the string \\Microsoft\\Internet Explorer\\Quick Launch) to get the location of the Quick Launch folder and store that value in a variable named strFolder:<\/P><PRE class=\"codeSample\">strFolder = colEnvironmentVariables.Item(&#8220;APPDATA&#8221;) &amp; _\n &#8220;\\Microsoft\\Internet Explorer\\Quick Launch&#8221;\n<\/PRE>\n<P>So much for task number 1. Task number 2 involves creating the shortcut for Notepad.exe, something we do here:<\/P><PRE class=\"codeSample\">Set objShortCut = objShell.CreateShortcut(strFolder &amp; _\n &#8220;\\Notepad.lnk&#8221;)\nobjShortCut.TargetPath = &#8220;Notepad.exe&#8221;\nobjShortCut.Description = &#8220;Open Notepad&#8221;\nobjShortCut.Save\n<\/PRE>\n<P>We start off by calling the <B>CreateShortcut<\/B> method, passing it the path to the Quick Launch folder plus <B>\\Notepad.lnk<\/B>, the file name for our new shortcut. We then set the following properties of the new shortcut:<\/P>\n<TABLE id=\"EQE\" class=\"dataTable\" cellSpacing=\"0\" cellPadding=\"0\">\n<THEAD><\/THEAD>\n<TBODY>\n<TR class=\"record\" vAlign=\"top\">\n<TD>\n<P class=\"lastInCell\"><B>Property<\/B><\/P><\/TD>\n<TD>\n<P class=\"lastInCell\"><B>Description<\/B><\/P><\/TD><\/TR>\n<TR class=\"evenRecord\" vAlign=\"top\">\n<TD>\n<P class=\"lastInCell\">TargetPath<\/P><\/TD>\n<TD>\n<P class=\"lastInCell\">File name\/path to the &#8211; in this case &#8211; executable file we want to run any time we click the new shortcut. Because Notepad.exe is in the Windows path all we need to do is specify the file name: Notepad.exe.<\/P><\/TD><\/TR>\n<TR class=\"record\" vAlign=\"top\">\n<TD>\n<P class=\"lastInCell\">Description<\/P><\/TD>\n<TD>\n<P class=\"lastInCell\">\u201cTool tip\u201d for the shortcut. (That is, the comment that appears when you hold the mouse over the shortcut.)<\/P><\/TD><\/TR><\/TBODY><\/TABLE>\n<DIV class=\"dataTableBottomMargin\"><\/DIV>\n<P>That\u2019s all we really need to do. There <I>are<\/I> other properties we can set for our shortcut; for a more complete list, take a look at the <A href=\"http:\/\/msdn.microsoft.com\/library\/en-us\/script56\/html\/wsObjWshShortcut.asp\" target=\"_blank\"><B>Windows Script Host Reference<\/B><\/A> on MSDN. For our purposes, however, we\u2019ll simply set the TargetPath and Description, and then call the <B>Save<\/B> method to save the new shortcut to the Quick Launch bar:<\/P><PRE class=\"codeSample\">objShortCut.Save\n<\/PRE>\n<P>Child\u2019s play.<\/P>\n<P>By the way, we know of another interesting piece of trivia regarding Home Run Baker, but TechNet probably wouldn\u2019t appreciate it if we related that information here. If you\u2019re interested, though, just search for <B>Home Run Baker<\/B> and &#8211; uh, well, never mind. Let\u2019s just remember Home Run Baker for leading the league in home runs four times and call it good.<\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hey, Scripting Guy! How can I add a shortcut to the Quick Launch tray?&#8212; ZR Hey, ZR. Before we answer this question we need to first answer a different question. And here\u2019s the answer: Frank \u201cHome Run\u201d Baker, who led the major league in homers four times, even though he never hit more than a [&hellip;]<\/p>\n","protected":false},"author":595,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[16,3,94,5],"class_list":["post-69043","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-desktop-management","tag-scripting-guy","tag-special-folders","tag-vbscript"],"acf":[],"blog_post_summary":"<p>Hey, Scripting Guy! How can I add a shortcut to the Quick Launch tray?&#8212; ZR Hey, ZR. Before we answer this question we need to first answer a different question. And here\u2019s the answer: Frank \u201cHome Run\u201d Baker, who led the major league in homers four times, even though he never hit more than a [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/69043","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/595"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=69043"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/69043\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=69043"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=69043"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=69043"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}