Export (0) Print
Expand All
GUI
Expand Minimize

Creating Your Own HTAs

Try It Yourself: Display Process Names and IDs in an HTA


Shows how to display two properties – process name and process ID – in an HTA. This is the answer to a Try It Yourself exercise found in the introductory tutorial on creating HTAs.



<head>
<title>HTA Test</title>
<HTA:APPLICATION 
     APPLICATIONNAME="HTA Test"
     SCROLL="yes"
     SINGLEINSTANCE="yes"
>
</head>

<script language="VBScript">

    Sub GetProcesses

        strComputer = "."

        Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
        Set colProcesses = objWMIService.ExecQuery("Select * from Win32_Process")

        For Each objProcess in colProcesses
            strHTML = strHTML & objProcess.Name & " -- " & objProcess.ProcessID & "<br>"
        Next

        DataArea.InnerHTML = strHTML

    End Sub

</script>

<body>
<input type="button" value="Processes" name="run_button"  onClick="GetProcesses">
<p>
<span id = "DataArea"></span>

</body>



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