1

我的 hta 文件上有一个按钮,当我点击它时会触发批处理文件运行。我希望用户在文本框中输入计算机名称,并在下面需要计算机名称的 psexec 命令中使用它。任何建议将不胜感激。

<script language="VBScript">
Sub InstallVNC
    dim shell
    set shell=createobject("wscript.shell")
    shell.run "psexec -u domain01\username -p password \\textbox1.value -c \\doamin\SHARE\SOFTWARE\install_program.bat"
End Sub


<body bgcolor="buttonface">
<p><font face="verdana" color="red">Application Installer</font></p>
Please run as administrator. <p>
<form name="test">
<font>Computer Name:</font>
<input type="text" name="textbox1" id="textbox1">
</form>
<input id=runbutton  class="button" type="button" value="Install VNC" name="db_button"  onClick="installvnc"><p>

</body>
</html>
4

2 回答 2

2

您需要以不同的方式处理输入字符串。像这样的东西:

Sub InstallVNC
  dim shell
  dim strInput
  dim shell_parameter
  strInput = textbox1.value
  shell_parameter = "psexec -u domain01\username -p password \\" & strInput  & " -c   \\doamin\SHARE\SOFTWARE\install_program.bat"
  set shell=createobject("wscript.shell")
  shell.run shell_parameter
End Sub

关于获取用户输入:我没有<form>在 hta 中使用过——对话框一直比较简单。我想知道这是否能让你解决问题。按下按钮时将调用此代码:

Dim strDialogPrompt, strDialogTitle, strDialogDefault

strDialogTitle = "File location"

strDialogPrompt = "Enter location of file to install." _
    & vbCrLf & "(You must run this as Administrator.)"

strDialogDefault = "Z:\The_Usual_Path"

strInput = InputBox(strDialogPrompt, strDialogTitle, strDialogDefault, 150, 150)
于 2013-08-05T03:17:48.840 回答
0

基本的 DOM 操作:

Dim computerName
computerName = document.getElementById("textbox1").value

有关更多信息,您几乎可以查阅任何 DOM 参考资料(例如,https ://developer.mozilla.org/en-US/docs/DOM )

于 2013-08-05T06:32:58.247 回答