Begginer at HTA - List box with a selection button

Batch, ASP, JScript, Kixtart, etc.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 16 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
djcalvin97
Posts: 1
Last visit: Fri Nov 09, 2007 7:47 am

Begginer at HTA - List box with a selection button

Post by djcalvin97 »

Im just dabbling into HTA's as i am trying to put a pretty face on all my vbscripts.
I grabbed this example from the scriptingguys webcast a while ago, and I just would like to know how to make the selection run with a "Run Script" button.. so that it doesnt run automatically. I just want 1 to run, but I want to have to choose the selection, then hit run. (and it would fire off the sub)

Here is the code:

Code: Select all

<head>
<title>HTA Helpomatic</title>
<HTA:APPLICATION 
     ID="objHelpomatic" 
     APPLICATIONNAME="HTAHelpomatic"
     SCROLL="no"
     SINGLEINSTANCE="yes"
     WINDOWSTATE="maximize"
>
</head>
<SCRIPT LANGUAGE="VBScript">
    Sub Processes
        strComputer = "."
        Set objWMIService = GetObject("winmgmts:" & strComputer & "rootcimv2")
        Set colProcesses = objWMIService.ExecQuery("Select * From Win32_Process")
        For Each objProcess in colProcesses
            strHTML = strHTML & objProcess.Name & ", " & objProcess.WorkingSetSize & "
"
        Next
        DataArea.InnerHTML = strHTML
    End Sub
    Sub Services
        strComputer = "."
        Set objWMIService = GetObject("winmgmts:" & strComputer & "rootcimv2")
        Set colServices = objWMIService.ExecQuery("Select * From Win32_Service")
        For Each objService in colServices
            strHTML = strHTML & objService.Name & ", " & objService.State & "
"
        Next
        DataArea.InnerHTML = strHTML
    End Sub
    Sub DiskSpace
        strComputer = "."
        Set objWMIService = GetObject("winmgmts:" & strComputer & "rootcimv2")
        Set colDisks = objWMIService.ExecQuery("Select * From Win32_LogicalDisk")
        For Each objDisk in colDisks
            strHTML = strHTML & objDisk.DeviceID & ", " & objDisk.FreeSpace & "
"
        Next
        DataArea.InnerHTML = strHTML
    End Sub
    Sub ChooseScript
        If ScriptChooser.Value = "Services" Then
            Call Services
        End If 
        If ScriptChooser.Value = "Processes" Then
            Call Processes
        End If 
        If ScriptChooser.Value = "DiskSpace" Then
            Call DiskSpace
        End If 
    End Sub
</SCRIPT>

<body>
<select size="3" name="ScriptChooser" onChange="ChooseScript">
<option value="Processes">Processes</option>
<option value="Services">Services</option>
<option value="DiskSpace">Disk Space</option>
</select>
<p>
<span id = "DataArea"></SPAN>
</p>
</body>

thank you
- Cal
This topic is 16 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked