Tuesday 6 March 2012

How to Add an Exit Function to a HTA


Following my previous post about the WScript.sleep function, here is an function to add to an exit function to a HTA.


Again, using HTA is really useful to bring life to a VBScript by adding an interface. So, converting your VBScript files to a HTA is not really complicated as VBScript is native, however some functions like the WScript.Quit are not available.


In a HTA, an easy way of exiting is to call the close method of the current Window object (self). Then, you have just to call the sbExitHTA sub to close the Window.


Also, if you want to get rid of the close button from the Windows title bar, add SysMenu="no" in the HTA:APPLICATION section.


<html>
<head>
<title>Simple HTA</title>
<HTA:APPLICATION
     ID="oSimpleHTA"
     APPLICATIONNAME="SimpleHTA"
>
</head>
<script Language="VBScript">
Sub Window_Onload
      dataarea.innerhtml = "<p>This is a simple HTA</p>" & _
      "<p>Exit button: </p>" & _
      "<input type=""button"" value=""Exit"" onClick=""sbExitHTA"" />"
End Sub
Sub sbExitHTA
      Self.Close()
End Sub
</script>
<body>
    <h1>Simple HTA</h1>
    <span id="dataarea"></span>
</body>
</html>

2 comments:

  1. Slots Vegas Casino - Mapyro
    Find the best slots 포천 출장샵 Vegas Casino in. ✓ New, 울산광역 출장샵 Best Price 영천 출장안마 Guarantee ➤ 의정부 출장샵 Mapyro® Casino Map ✓ No Deposit Bonuses ✓ Real Money! 양주 출장안마

    ReplyDelete