Sign in to follow this  
Followers 0
Guest lucindrea

comd.exe - program done?

8 posts in this topic

ok i have done a few searches and havent been able to come up with what i want to do ..

basicly i'm running a command in a dos shell and it scrolls by going 10.1% 10.2% , etc up untill 99% .. it never acctully shows 100% , what happens is that it goes from 98% ish ( doesnt show every 0.1% , just what ever it's up to every 1 second ) then prints out a "DONE!" ...

the problem i have is that this can take 30 seconds to go from 0% to 100% , or it can take 10 mins ... i need to be able to monitor the cmd window and wait for the DONE! to come up so i can go on to the next part of the autoit script.

is their a simple way to do this? , if not checking for the DONE! , perhaps their is a way to monitor the process and if it uses less then 1% cpu i can concider it finished , of course i havent a clue how to do that either or if it's even possable.

Share this post


Link to post
Share on other sites



ok i was able to work this out myself , basicly i just ran the program directly and did a winwaitclose :)

Share this post


Link to post
Share on other sites

Or the good:

$Pid = Run('filename.exe')

;Do what ever you want to do while waiting.

ProcessWaitClose($Pid)

Share this post


Link to post
Share on other sites

I'm also a big fan of checking the errorlevel returns in addition to the process existence -- trapping the return from the runwait will ensure that you got a DONE!, rather than FAILED!!


Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Yeah, lucindrea. Try to cast your program and check its exitlevel value, (if any) with

echo %errorlevel%

So you can use it the script

E.g.

$el = RunWait('myprogram.exe')
Select
   Case $el = 1
      msgbox(0,'Faliure','Gasp. Something goes wrong!')
   Case $el = 0
      msgbox(0,'Success','Love it.')
   Case Else
      msgbox(0,'Well.. Dunno..','I can't tell')
EndSelect

Edit: fixed. Thanks sugi.

Edited by ezzetabi

Share this post


Link to post
Share on other sites

Just a quick note: Run() cannot and does not return the errorlevel but RunWait() does.

Share this post


Link to post
Share on other sites

Yes, of course. Run() returns the Pid as shown in the other example of mine few posts before.

Thanks Sugi.

Share this post


Link to post
Share on other sites

works great thanks , and the error checking is a nice bonus :)

Share this post


Link to post
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
Sign in to follow this  
Followers 0