Export (0) Print
Expand All
GUI
Expand Minimize

Creating Your Own HTAs

Try It Yourself: Add a Button to an HTA


Shows how to add a button (with the label Service Pack) to an HTA. This is the answer to a Try It Yourself exercise found in the introductory tutorial on creating HTAs.



<head>
<title>Operating System Version</title>
<HTA:APPLICATION 
     APPLICATIONNAME="Operating System Version"
     SCROLL="yes"
     SINGLEINSTANCE="yes"
>
</head>

<script language="VBScript">

    Sub GetOSVersion
       strComputer = "."
           Set objWMIService = GetObject("winmgmts:\\" & strComputer &  "\root\cimv2")

           Set colOperatingSystems = objWMIService.ExecQuery _
               ("Select * from Win32_OperatingSystem")

           For Each objOperatingSystem in colOperatingSystems
               Msgbox objOperatingSystem.Caption & " " & _
                   objOperatingSystem.Version
           Next
    End Sub
</script>

<body>
<input type="button" value="Operating System" name="run_button"  onClick="GetOSVersion">
<input type="button" value="Service Pack" name="service_pack"  onClick="GetServicePack">

</body>



Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft