[HTA] How to hide the CMD prompt on HTA Script ?
Hi !
I wonder if there are any tricks or tips can be done to hide the CMD prompt when I execute this HTA script?
Thank you !
Code:
<html>
<head><title>Traceroute</title>
<HTA:APPLICATION ID="oHTA";
APPLICATIONNAME="Traceroute";
BORDER="thin";
BORDERSTYLE="normal";
SINGLEINSTANCE="no";
>
</head><body bgcolor="#E8E8E8" >
<font size=2 face="Century Gothic, Tahoma, Arial" color="black">
<script language="VBScript" type="text/vbscript">
set objShell = CreateObject("WScript.Shell")
strOut=""
sub traceroute
cmdarg="%comspec% /c tracert.exe " & T1.value
set objExCmd = objShell.Exec(cmdarg)
strOut=objExCmd.StdOut.ReadAll
Set regEx = New RegExp
regEx.Pattern = "[\f\n\r\v]+"
regEx.Global = True
regEx.Multiline = True
strOut = regEx.Replace(strOut, "<br>")
TraceOut.innerHTML= strOut
end sub
//-->
</script>
<p><b>Traceroute HTA by Paul R. Sadowski (11/2001)</b><hr noshode color="#000000"><br>
<p>Hostname: <input type="text" size="40" name="T1">
<input type="submit" name="B1" value="Submit" onclick="traceroute"></p>
<div id=TraceOut></div>
<script language="JavaScript">
<!--
if (window.resizeTo) self.resizeTo(600,400);
//-->
</script>
Re: [HTA] How to hide the CMD prompt on HTA Script ?
Redirect command output to a temporary file, run the command with objShell.Run instead of objShell.Exec, specifying the hide window option, then read the file using FileSystemObject.
Re: [HTA] How to hide the CMD prompt on HTA Script ?
Quote:
Originally Posted by
His Nibbs
Redirect command output to a temporary file, run the command with objShell.Run instead of objShell.Exec, specifying the hide window option, then read the file using FileSystemObject.
Thank you His Nibbs :thumb: for your reply!
So The Problem is solved like this as you said ;)
Code:
<html>
<head><title>Traceroute</title>
<HTA:APPLICATION ID="oHTA";
APPLICATIONNAME="Traceroute";
BORDER="thin";
SCROLL="yes"
SINGLEINSTANCE="yes"
WINDOWSTATE="Maximize"
icon="verifier.exe"
>
</head>
<META HTTP-EQUIV="MSThemeCompatible" CONTENT="YES">
<script language="VBScript" type="text/vbscript">
Function CmdPrompt(sCmd)
Dim strOut,alines, sCmdLine, stemp, ofs, oWS, nRes
sCmdLine = """%comspec%"" /c " & sCmd & " 1>> "
set ofs = CreateObject("Scripting.FileSystemObject")
stemp = ofs.GetTempName
set oWS = CreateObject("Wscript.Shell")
stemp = oWS.Environment("PROCESS")("TEMP") & "\" & stemp
nRes = oWS.Run(sCmdLine & Chr(34) & sTemp & Chr(34),0,True)
if ofs.FileExists(sTemp) Then
with ofs.OpenTextFile(stemp)
if Not .AtEndofStream Then
alines = aLines & .ReadAll
alines = Replace(aLines,"‚","é")
alines = Replace(alines,VbNewLine,"<br>")
Message.style.visibility="visible"
document.body.style.cursor = "default"
TraceOut.InnerHTML = aLines
End if
End With
ofs.DeleteFile stemp
alines = Split(aLines, vbNewline)
Else
aLines = Array(nRes, "")
End if
ReDim Preserve alines(Ubound(alines) - 1)
if Err.Number <> 0 Then _
aLines = Array("Error Number:" & CStr(Err.Number),Err.Description)
CmdPrompt = alines
Message.style.visibility="visible"
document.body.style.cursor = "default"
TraceOut.InnerHTML = alines
End Function
Sub Execution()
Message.InnerHTML = "<center><hr noshode color=""#000000""><b><font color='DarkOrange' size='5'>Détermination de l'itinéraire vers "&T1.Value&" </font><hr noshode color=""#000000"">"
document.body.style.cursor = "wait"
Call CmdPrompt("Tracert "&T1.Value&"")
End Sub
</script>
<body bgcolor="#12345678" text=white>
<center><font size=3 face="Century Gothic, Tahoma, Arial" color="White">
<p><b>Traceroute</b><hr noshode color="#000000"><br>
<p>Nom de la Hôte ou bien son adresse IP: <input type="text" size="25" name="T1" Value="www.tek-tips.com"></font></center>
<center><p><input type="submit" name="B1" value="Tracer la Hôte" onclick="Execution()"></p></center>
<span id ="Message"><hr noshode color="#000000"></span>
<font size=3 face="Century Gothic, Tahoma, Arial" color="White"><div id=TraceOut></div></font>
</body>