Jump to content

command window wait for process


Recommended Posts

If I want to run a series of tests in the dos command window, how to I tell autoit to pause until an operation is done? Not using Sleep() of course :whistle:

For example:

(AutoIt Script: Send("xxx.exe"), Send("{ENTER}"))

(Shown on cmd.exe)

C:\Documents and Settings\user name>xxx.exe

xxx.exe installing... please wait

xxx.exe finished installing

Continue AutoIt script

Link to comment
Share on other sites

Im running different test programs and they may not always end up with the same "installation done" line. Anyway AutoIt cant detect lines from a dos window. Is there a way to check the process of a window and when it is done? Im not sure how to use the ProcessWait() command in my script tho. Any help would be nice.

Edited by probedrone
Link to comment
Share on other sites

If you're using 3.2 you may wish to take a look at the StdOutRead() function.

Yea Im kinda newbie at AutoIt. I got beta but cant figure out how stdoutread can help in my program, any advice (or piece of code) would be great.

Also, omglol, it would be best if your solution can work, but I dont know what "Installation" is. Am I supposed to fill in the name of my own program? How do I do that if the process is not shown?

Link to comment
Share on other sites

Suppose you have this batch file that puts stuff up on the screen periodically:

@echo off
set _wf=%TEMP%\~wait.tmp
echo wscript.sleep WScript.Arguments(0)>%_wf%

echo Starting_1
echo Here is where you do something
cscript %_wf% 5000 //NOLOGO //E:VBSCRIPT
echo Done_1
cscript %_wf% 5000 //NOLOGO //E:VBSCRIPT

echo Starting_2
echo Here is where you do something else
cscript %_wf% 7000 //NOLOGO //E:VBSCRIPT
echo Done_2

cscript %_wf% 5000 //NOLOGO //E:VBSCRIPT
del %_wf%
set _wf=

You can use something like this to tell what is going on:

SplashTextOn("MyProgress", "Now installing", 300, 100)
$CHILDDOS = Run(@ComSpec & ' /c "' & @ScriptDir & '\test.bat"', @ScriptDir, @SW_MINIMIZE, 2)

While 1
    $Status = StdoutRead($CHILDDOS)
    If @error Then ExitLoop
    Select
        Case StringInStr($Status, "Starting_1")
            ControlSetText("MyProgress", "", "Static1", "Now installing program 1")
        Case StringInStr($Status, "Done_1")
            ControlSetText("MyProgress", "", "Static1", "Done install 1")
        Case StringInStr($Status, "Starting_2")
            ControlSetText("MyProgress", "", "Static1", "Now installing program 2")
        Case StringInStr($Status, "Done_2")
            ControlSetText("MyProgress", "", "Static1", "Done install 2")
    EndSelect
    Sleep(10)
WEnd

SplashOff()
Edited by bluebearr
BlueBearrOddly enough, this is what I do for fun.
Link to comment
Share on other sites

Yea Im kinda newbie at AutoIt. I got beta but cant figure out how stdoutread can help in my program, any advice (or piece of code) would be great.

Also, omglol, it would be best if your solution can work, but I dont know what "Installation" is. Am I supposed to fill in the name of my own program? How do I do that if the process is not shown?

I wouldn't know for sure if it would work in the first place, you'd have to check that out by yourself...

anyways i'm sorry that i didn't clearafy that when i posted the piece of code, but when you type ProcessExists( it'll show you to put the name of the process in there, wich will be in the task manager when you've started the installation at processes i think, never worked with it myself,

again it's up to you to test it out :whistle:

good luck.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...