关闭hta后即可执行命令

时间:2013-09-21 08:08:25

标签: javascript vbscript hta

我已经设置了cmd命令aruments

@echo off
ping 127.0.0.1 -n 10
netsh wlan stop hosted

如果单击hta中的按钮,即使我关闭hta窗口也不应该停止,这些需要在后台执行。即,hta存在,但上面的代码在后台执行。我该怎么办?

1 个答案:

答案 0 :(得分:0)

这可能会让你顺利回答......

<html>
    <head>
    <title>Ping Ping</title>
    <hta:application
         scroll="no"
         singleinstance="no"
         windowstate="normal"
    >
    </head>

<script type="text/vbscript">

Sub PingSub
  Dim WSHShell
  Dim ComputerName
  ComputerName = "127.0.0.1"

  Set WSHShell = CreateObject("WScript.Shell")
  WSHShell.Run("%comspec% /k ping " & ComputerName & " -t")
End Sub

</script>

<body>

<input id="btnBrowse" type="button" value="Run Pings..." onClick="PingSub" />

</body>
</html>