我想運行一個HTA文件,其中有一個父HTA調用一個子HTA以定期顯示更新的循環。我希望孩子的HTA在舊版本中保持打開狀態,並且在新的更新中再次調用它時應該關閉,然後重新啓動它。我試圖做到這一點,但我無法爲孩子HTA添加密切的HTA條件。這導致所有Child HTA在後臺打開。關閉子HTA文件的方法,如果它從父HTA文件再次被調用
家長HTA文件,
代碼打開孩子HTA前下方
<html>
<head>
<title>Parent Application</title>
<HTA:APPLICATION
APPLICATIONNAME="Parent Application"
ID="ParentApplication"
VERSION="1.0"/>
</head>
<script language="VBScript">
Sub OnClickButtonConnect()
Dim currentDirectory,pos
pos=InStrRev(document.location.pathname,"\")
currentDirectory=""
If pos>0 Then
currentDirectory = Left(document.location.pathname,pos)
End If
Dim WshShell, i, g
g = 5
set WshShell = CreateObject("wscript.Shell")
For i = 1 To g
cmdline = "mshta.exe """ & currentDirectory & "child.hta"" """ & login.value & """ """ & password.Value & """"
WshShell.Run cmdline,1,False
next
window.close
End Sub
</script>
<body bgcolor="white">
<!--Add your controls here-->
Login:<input type="text" name="login" id="login"><BR>
Password:<input type="password" name="password" id="password"><BR>
<input type="button" name="Connect" id="Connect" value="Connect" onclick="OnClickButtonConnect">
<!--{{InsertControlsHere}}-Do not remove this line-->
</body>
</html>
兒童HTA給出
<html>
<head>
<title>Child Application</title>
<HTA:APPLICATION
APPLICATIONNAME="Child Application"
ID="ChildApplication"
VERSION="1.0"/>
</head>
<script language="VBScript">
Sub Window_OnLoad
str=""
arguments = Split(ChildApplication.CommandLine," """)
For i=0 To UBound(arguments)
arguments(i)=Replace(arguments(i),"""","")
Next
document.body.innerhtml="login is: " & arguments(1) & "<BR>password is: " & arguments(2)
End Sub
</script>
<body bgcolor="white">
<!--Add your controls here-->
<!--{{InsertControlsHere}}-Do not remove this line-->
</body>
</html>
任何一個請幫忙 –
嘗試編輯您的問題併發布您的HTA代碼! – Hackoo
您可以將命令行添加到您的WMI查詢中的子HTA中,以選擇要關閉的進程嗎? '從Win32_Process中選擇*其中的CommandLine像'%'child.hta%'' – langstrom