等待Cmd提示时VBS冻结

时间:2016-05-23 16:55:01

标签: vbscript wsh

难以制作一个简洁的标题,但基本上,我已经从VBS启动了一个命令提示实例来运行一个exe,一切都很好,我用输出行的msgbox验证了我的反馈。当命令提示符到达正在加载的部分并显示验证文件(XX%)时,VBS不再运行。它不会崩溃,它根本不会从它的线上移动。我甚至注意到,如果我不经常使用Writeline,它会在此之前暂停。因此,当我等待的时候,我经常写一个1.我没有看到任何地方它可能在一个无限循环而没有向我显示消息框。

请帮忙。

set shell = WScript.CreateObject("WScript.Shell")
set oExec = Shell.exec("cmd.exe")
do while Not oExec.StdOut.AtEndOfStream
        junkChar = oExec.stdOut.Read(1)
        message = message & junkChar
        'errormsg = oExec.stderr.readline
        if asc(junkChar) = 13 and message <> junkChar then
            msgbox message '& len(message)
            message = ""
        end if
        if right(message,1) = ">" and not bool1stCmd then
            'msgbox(message)
            msgbox("Command" & cmdArchive)
            oExec.stdIn.Writeline cmdArchive
            bool1stCmd = True
            'oExec.StdIn.Write VbCrLf
        elseif bool1stCmd then
            if InStr(1,message,"Enter a command>")>0 then
                msgbox "Enter a command!"
            end if
            oExec.stdIn.writeline "1"
        end if
        msgbox "Loop again!"
    Loop
    msgbox "exiting loop"

0 个答案:

没有答案
相关问题