WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

DOS

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Waiting for DOS applications to finish

Keywords:  DOS wait runwait  FileExist delay

Here is the situation:

The user is running a WinBatch script that is launching a DOS program, which then creates reports. Once the reports start, he needs to wait until they are finished, before he proceeds with his script. The DOS pif needs to be set to close on exit. If the DOS program is closing on exit, he can use a second script to handle the wait. If he needs to send an exit, he'll have to have an event driven delay.

Here are some examples for him to consider:

DOS PIF closing on exit:

His first script should handle all of his keystrokes up to the point that the reports are run. Then a second script can be written to check for the program to go away before it continues.

;;First WBT file 
;;Starts and runs the second script and does all keystrokes up to the report generation.

Run("2ndwbt.wbt", "")

SendKeys...     ; send the relevant keys here
SendKeys...     ; same as above
SendKeys...     ; same as above

;; Reports are being generated.  The reports finish, and the DOS application
;; closes because the DOS PIF is set to Close On Exit

exit
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;2ndwbt.wbt     
;;Checks for the existence of the DOS app.  When it closes, the script continues 
;;with the rest of the code he would like to have executed.

While WinExist("DOS Program")
        timedelay(2)
endwhile
;;Dos program is done, has closed, and script continues.
Sendkeys
;;etc.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

If he needs to send a keystroke to close the program, then he needs to pause while processing continues. If certain reports are generated when the program has finished, then check for the existence of these reports:

While ! FileExist("report1.xxx")
        timedelay(2)
endwhile

To check for more than one file, you must have separate checks:

While ! FileExist("report1.xxx") && FileExist("report2.xxx") &&
FileExist("report3.xxx")
        timedelay(2)
endwhile
To read the additional information on creating delays, search for "wait" elsewhere on these Web pages.
Article ID:   W12908
Filename:   Waiting for DOS apps to finish.txt
File Created: 1999:04:15:16:50:28
Last Updated: 1999:04:15:16:50:28