<HTML> <HEAD> <TITLE> MSDOS Demo</TITLE> <HTA:APPLICATION ID="oMSDOS" APPLICATIONNAME="MSDOSApp" BORDER="thick" BORDERSTYLE="normal" CAPTION="yes" ICON="C:\WinNT\system32\cmd.exe" MAXIMIZEBUTTON="yes" MINIMIZEBUTTON="yes" SHOWINTASKBAR="yes" SINGLEINSTANCE="no" SYSMENU="yes" VERSION="1.0" WINDOWSTATE="normal"/> <SCRIPT Language=VBScript> opener = "Me" sub initialize CurrentFolder.value = CreateObject("Wscript.Shell").CurrentDirectory Cmd.focus end sub Function CmdPrompt(sCmd) Dim alines, sCmdLine, stemp, ofs, oWS, nRes 'On Error Resume Next 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) _ , Abs(cSng(bConsoleSw)), True) alines = "ERRORLEVEL: " & nRes & vbCRLF if ofs.FileExists(sTemp) Then with ofs.OpenTextFile(stemp) if Not .AtEndofStream Then alines = aLines & .ReadAll 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 End Function sub checkEnter With window.event if .keycode = 13 then runMS_DOS Else .cancelbubble = false .returnvalue = true End if End With End sub Sub ChDir Set oSHL = CreateObject("Shell.Application") On Error Resume Next Set oFolder = oSHL.BrowseForFolder(&H0,"Select Working Folder",&H11,&H11) If Err.Number = 0 Then CurrentFolder.value = oFolder.Self.Path Cmd.focus End if End Sub Sub runMS_DOS 'On Error Resume Next CreateObject("Wscript.Shell").CurrentDirectory = CurrentFolder.value if Err.Number <> 0 Then aLines = Array("Error Number:" & Hex(Err.Number), Err.Description) Else Results.innerhtml = "</b> Working ...</b>" aLines = CmdPrompt(Cmd.Value) End if Results.innerhtml = "<xmp>" & Join(aLines, vbCRLF) & "</xmp" End Sub </SCRIPT> </HEAD> <BODY onload=initialize> </B>Working Folder: &nbsp; &nbsp; </B> <input type=text id=CurrentFolder size=70> <input type=button value=Browse onclick=ChDir> <br> </B>MS DOS Command: </B> <input type=text onkeydown=checkEnter size=60 id=Cmd>&nbsp; <input type=button id=Go value=" GO " onclick=runMS_DOS> <hr> <framset> <frame id=ResultFrm> <div id=Results>&nbsp</div> </frame> </frameset> <hr><center> <input type=button value=" Top " onclick="scrollto 0,0:Cmd.focus:Cmd.Select"> &nbsp <input type=button value=" Close " onclick="close"> </center> </BODY> </HTML>