Jump to content

Recommended Posts

Posted

Hi, I am redirecting Command Prompt logs into a text file, How can I know (programmatically) that this txt file has been released by DOS and I can use it?

I tried by time modification, but it appeared that this time changes while DOS still writing in it.

I can see that DOS complete its work  from the DOS window, but how can I find it out programmatically?

Thanks

  • Moderators
Posted

You can always use StdoutRead to capture the output and watch for it. Something like this should get you started:

#include <Constants.au3>


$cmd = Run(@ComSpec & " /c echo Testing>C:\File.txt", "C:\", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)

While 1
    $line = StdoutRead($cmd)
        If @error Then ExitLoop
            If $line <> "" Then MsgBox(0, "STDOUT read:", $line)
Wend

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Posted

You are right, but my problem is I am executing several commands in DOS and each of them writes in the log.

1. execute DOS command1 > log.txt

2. analyze the log

3. execute DOS command2 > log.txt

4. analyze the log

between step 1 and 2 I must be sure that the log is finalized and released by DOS, and only after that I can do step 2.

  • Moderators
Posted

So look at the StdoutRead in a MsgBox, and see what line is shown in the DOS window when it completes after step 1. In your While statement, look for that line in StdoutRead.

Also, are these DOS commands from some other application, or commands you are executing yourself? If it is the latter, why not cut out the middle man and do it all in AutoIt?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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
  • Recently Browsing   0 members

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