我正在尝试使用简单的HTA在Active Directory上运行查询,然后输出将是可选择的选项。我无法弄清楚的部分是如何制作选择部分。
Sub User
set objExec = objshell.Exec(dsquery user -name "UserName")
set objStdOut = objExec.StdOut
strLine = objStdOut.ReadAll
Results.value = StrLine
End Sub
此代码将输出到textarea。
<textarea name="Results">
然后我想成为可选择的选项。因此,例如,如果我有多个名为“Smith”的用户,那么我可以选择我想要的用户并使用该信息运行另一个查询。
如果有比textarea更好的解决方案,我愿意接受消化。我只是不希望它是一个下拉列表或单选按钮。
感谢任何帮助
答案 0 :(得分:1)
来自 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>