2

I am trying to make a simple HTA to run queries on Active Directory and then the output would be selectable options. The part I am unable to figure out is how to make the selections portion.

Sub User
    set objExec = objshell.Exec(dsquery user -name "UserName")
    set objStdOut = objExec.StdOut
    strLine = objStdOut.ReadAll
    Results.value = StrLine
End Sub

This code will output to a textarea.

<textarea name="Results">

Which I would then like to be selectable options. So if for example I have multiple users with the name 'Smith' then I can select the one I want and run another query with that information.

If there is a better solution than a textarea I am open to sugestions. I just dont want it to be a dropdown or radio button.

any help is appreciated

Hackoo
  • 18,337
  • 3
  • 40
  • 70
  • Did you mean something like this ??? ==> http://stackoverflow.com/questions/35198533/get-output-of-a-powershell-script-in-a-hta/35267951#35267951 – Hackoo Jun 23 '16 at 20:04
  • @Hackoo Basically what I am looking for is this dsquery user -name "smith*" will return 2 users Smith, John Smith, Mike I want to be able to click on 1 and have it select that user to run another command – user3527088 Jun 23 '16 at 20:07

1 Answers1

1

This an example from How Can I Dynamically Populate a List Box in an HTA ?

<html>
<head>
<title>Local Users</title>
<HTA:APPLICATION
     ID="objHTAHelpomatic"
     APPLICATIONNAME="LocalUsers"
     SCROLL="yes"
     SINGLEINSTANCE="yes"
     WINDOWSTATE="maximize"
>
</head>
<SCRIPT Language="VBScript">
    Sub Window_Onload
        Set objNetwork = CreateObject("Wscript.Network")
        strComputer = objNetwork.ComputerName
        Set colAccounts = GetObject("WinNT://" & strComputer & "")
        colAccounts.Filter = Array("user")
        For Each objUser In colAccounts
            Set objOption = Document.createElement("OPTION")
            objOption.Text = objUser.Name
            objOption.Value = objUser.Name
            LocalUsers.Add(objOption)
        Next
    End Sub
'*********************************************************************
Sub Execute()
    Dim UserVar,ws
    UserVar = LocalUsers.value
    Command = "cmd /k Title Execution of NET USER for "& DblQuote(UserVar) &" & net user "& UserVar &""
    set ws = CreateObject("wscript.shell")
    ws.run Command
End Sub
'*********************************************************************
Function DblQuote(Str)
    DblQuote = Chr(34) & Str & Chr(34)
End Function
'*********************************************************************
</SCRIPT>
<body>
Command Net User<br><br>
    <select name="LocalUsers"></select>
    <input type="button" value="Execute Command Net User" onclick="Execute()">
</body>
</html>
Hackoo
  • 18,337
  • 3
  • 40
  • 70