{"id":68313,"date":"2005-12-16T12:09:00","date_gmt":"2005-12-16T12:09:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2005\/12\/16\/how-can-i-create-an-hta-that-doesnt-have-a-close-button-in-the-title-bar\/"},"modified":"2005-12-16T12:09:00","modified_gmt":"2005-12-16T12:09:00","slug":"how-can-i-create-an-hta-that-doesnt-have-a-close-button-in-the-title-bar","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/how-can-i-create-an-hta-that-doesnt-have-a-close-button-in-the-title-bar\/","title":{"rendered":"How Can I Create an HTA that Doesn\u2019t Have a Close Button in the Title Bar?"},"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 create an HTA that doesn\u2019t have a <B>Close<\/B> button in the title bar?<BR><BR>&#8212; AK<\/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, AK. You know, you\u2019ve presented us with a great moral and ethical quandary. After all, suppose we answer this question: suddenly the world might be inundated with HTAs that couldn\u2019t be closed. We have this vision of unclosable, unstoppable HTAs sweeping unchecked throughout the land, gobbling up any and all system resource in their paths. And we, the Scripting Guys, would be responsible for that. We just don\u2019t think we could live with such a thing on our consciences.<\/P>\n<P>But, then again, what difference will it make to have one more thing on <I>our<\/I> consciences? With that in mind, here\u2019s an HTA that can\u2019t be closed; the only way to get rid of it is to terminate the Mshta.exe process (or have the Army Air Corps try to shoot it down off the top of the Empire State Building):<\/P><PRE class=\"codeSample\">&lt;html&gt;\n&lt;head&gt;\n    &lt;title&gt;Test&lt;\/title&gt;\n&lt;\/head&gt;<\/p>\n<p>&lt;HTA:APPLICATION \n    SysMenu=&#8221;no&#8221;\n&gt;<\/p>\n<p>&lt;body&gt;\n    &lt;p&gt;This HTA has no Close button.&lt;\/p&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;\n<\/PRE>\n<P>And when you run the thing, you should see something that looks like this:<\/P><IMG border=\"0\" alt=\"HTA\" src=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/qanda\/noclose1.jpg\" width=\"399\" height=\"254\"> \n<P><BR>So how did we get rid of the Close button (not to mention the Minimize and Maximize buttons) yet still keep the window title bar? That\u2019s easy: all we did was set the value of the <B>SysMenu<\/B> property to <B>no<\/B>:<\/P><PRE class=\"codeSample\">&lt;HTA:APPLICATION \n    SysMenu=&#8221;no&#8221;\n&gt;\n<\/PRE>\n<P>That\u2019s it: setting the value of SysMenu to no (which must be done inside the HTA:APPLICATION tag) will get rid of the Close button, the Minimize and Maximize buttons, and the system menu. You can still move the window around (just click on the title bar and drag), but there\u2019s no way to close the window.<\/P>\n<P>And, yes, our consciences <I>are<\/I> bothering us a little. (Although that\u2019s probably because we drank the last of the coffee but were too lazy to make a new pot.) Here\u2019s a revised HTA that doesn\u2019t have a Close button in the title bar; however, it <I>does<\/I> have a button in the body of the HTA labeled <B>Exit<\/B>. Click that button, and a subroutine named ExitProgram will close the HTA window for you:<\/P><PRE class=\"codeSample\">&lt;html&gt;\n&lt;head&gt;\n    &lt;title&gt;Test&lt;\/title&gt;\n&lt;\/head&gt;<\/p>\n<p>&lt;HTA:APPLICATION \n    SysMenu=&#8221;no&#8221;\n&gt;<\/p>\n<p>&lt;SCRIPT LANGUAGE=&#8221;VBScript&#8221;&gt;\n    Sub ExitProgram\n        window.close()\n    End Sub\n&lt;\/SCRIPT&gt;<\/p>\n<p>&lt;body&gt;\n    &lt;input id=runbutton type=&#8221;button&#8221; value=&#8221;Exit&#8221; onClick=&#8221;ExitProgram&#8221;&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;\n<\/PRE>\n<P>In this case, we end up with an HTA that looks like this:<\/P><IMG border=\"0\" alt=\"HTA\" src=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/qanda\/noclose2.jpg\" width=\"402\" height=\"255\"> \n<P><BR>All things considered, it\u2019s probably best to have <I>some<\/I> way to gracefully dismiss the HTA. But that\u2019s up to you. And <I>your<\/I> conscience.<\/P>\n<TABLE id=\"EJE\" class=\"dataTable\" cellSpacing=\"0\" cellPadding=\"0\">\n<THEAD><\/THEAD>\n<TBODY>\n<TR class=\"record\" vAlign=\"top\">\n<TD>\n<P class=\"lastInCell\"><B>Note<\/B>. If you\u2019ve read through this entire column and are still thinking, \u201cHT-whats?\u201d then you might want to check out the information in the <A href=\"http:\/\/null\/technet\/scriptcenter\/hubs\/htas.mspx\"><B>HTA Developers Center<\/B><\/A>, or &#8211; even better &#8211; view the <A href=\"http:\/\/msevents.microsoft.com\/CUI\/EventDetail.aspx?EventID=1032282307&amp;Culture=en-US\" target=\"_blank\"><B>Scripting Week 3 webcast<\/B><\/A> on creating HTAs.<\/P><\/TD><\/TR><\/TBODY><\/TABLE><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hey, Scripting Guy! How can I create an HTA that doesn\u2019t have a Close button in the title bar?&#8212; AK Hey, AK. You know, you\u2019ve presented us with a great moral and ethical quandary. After all, suppose we answer this question: suddenly the world might be inundated with HTAs that couldn\u2019t be closed. We have [&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":[3,4,30],"class_list":["post-68313","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-scripting-guy","tag-scripting-techniques","tag-web-pages-and-htas"],"acf":[],"blog_post_summary":"<p>Hey, Scripting Guy! How can I create an HTA that doesn\u2019t have a Close button in the title bar?&#8212; AK Hey, AK. You know, you\u2019ve presented us with a great moral and ethical quandary. After all, suppose we answer this question: suddenly the world might be inundated with HTAs that couldn\u2019t be closed. We have [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/68313","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=68313"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/68313\/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=68313"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=68313"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=68313"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}