RunWait and AppWaitClose failing to wait
The Loader Program Problem
Keywords: RunWait AppWaitClose not waiting failed wait loader
It is very popular now for programs to be launched from what we call loader exe's. For example both WordPerfect and Lotus use loader exe's.
Some setup programs actually spawn another EXE. Winbatch launches
SETUP.EXE and waits for it. SETUP.EXE then spawns another program and exits, therefore your
Winbatch exits.
When you find this is happening, wait for SETUP.EXE to terminate, then do a WinWaitClose for
the window spawned by SETUP.EXE. Here's the process:
- WinBatch runs the specified executable.
- Waits until specified application EXE is closed.
- Sees the executable close, so WinBatch continues on with the next line of the script.
To prevent WinBatch from continuing on until the real EXE is finished,
after your run statement do a WinWaitClose of the Window title that you want WinBatch to wait to
see before it continues on. Note that some applications change their
window title, and this fools WinWaitClose as it no longer sees the window title specified.
To fix this problem, use the following code....assuming the
window title at least starts out with "Welcome".
run("abc.exe","")
WinWaitExist("Welcome")
mywin=WinIdGet("Welcome")
WinWaitClose(mywin) ; now it will not be fooled by title changes
Or, more generically:
run("abc.exe","")
xxx=WinIdGet(WinGetActive())
WinWaitClose(xxx)
See info on
Partial WindowNames if you are not familiar with using them.
For information on finding the true exe name see:
Getting the EXE Name of a Loader
Be Aware
RunWait will also fail if your WinBatch version does not match your Windows Environment.
If you are using the 16 bit version of WinBatch under Windows 95 or NT, the RunWait command will fail.
Your WinBatch version must match your operating system version. Additionally, AppWaitClose will
fail if your application that you want to wait is a 16-bit app under Windows 95/NT. There's
a chance that you can get the AppWaitClose to work on your 16-bit app
if you use compile your WBT with the 16-bit compiler, but no promises here.
Additional details:
If you are using RunWait, and it doesn't work, then try using RunShell with the @WAIT
waitflag. If that doesn't work, try using RunShell with the @NOWAIT along with the
WinWaitClose function.
Article ID: W13107
Filename: RunWait - AppWaitClose Failing and Loader Programs.txt
File Created: 2017:08:29:11:48:30
Last Updated: 2017:08:29:11:48:30