我試圖從HTA文件內啓動批處理文件。批處理文件的啓動似乎正常啓動(或至少是相關的CMD提示),但批處理會在稍後關閉,此時應耗時約5分鐘。在短暫的CMD過程正在運行的過程中,HTA窗口似乎暫停,然後在CMD過程結束後立即關閉。有關HTA的其他一切都可以正常運行。從HTA內啓動批處理文件
目標是讓HTA在後臺啓動批處理文件(隱藏),並且在處理批處理文件時,不會影響HTA。批處理文件完成並退出後,HTA將啓動一個包含用戶信息的新HTA。
這裏的HTA我有不正常...
<html>
<head>
<style>
body { background:#fff url('../_dependencies/welcome.jpg') no-repeat center center fixed; color:#000; margin:25px; padding:0; }
div#gap { height:306px; }
div#buttons { padding-right:12px; position:absolute; right:0; }
</style>
<title>Installer</title>
<script language="vbscript">
Sub Window_OnLoad
Set Shell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
sPath = Shell.ExpandEnvironmentStrings("%curdir%")
Continue = Chr(34) & sPath & "_install.cmd" & Chr(34)
Shell.Run Continue,0,True
CompName = Shell.ExpandEnvironmentStrings("%computername%")
Const ForAppending = 8
textFile = sPath & "_Logs\" & CompName & ".upgraded.txt"
If Not objFSO.FileExists(textFile) Then
Set objTextFile = objFSO.CreateTextFile(textFile, True)
objTextFile.Close
End If
Set objTextFile = objFSO.opentextfile(textFile,ForAppending)
objTextFile.WriteLine("Upgrade complete on this computer." & vbCrLf & Now())
objTextFile.Close
Set textFile = Nothing
self.close()
End Sub
</script>
<script language="javascript">
window.resizeTo(620,365);
window.moveTo((screen.width-620)/2,(screen.height-365)/2);
</script>
<hta:application applicationname="Installer" border="none" caption="no" id="objnotitlebar" innerborder="no" maximizebutton="no" minimizebutton="no" scroll="no" showintaskbar="no" singleinstance="yes" systemmenu="no">
</head>
<body>
<div id="gap"><img src="../_dependencies/waiting.gif" /></div>
<div id="buttons"></div>
</body>
</html>
您還應該發佈'install.cmd'的源代碼 – Hackoo