Using WshShell.Run( ), bWaitOnReturn has no effect

Here's a simple one (I hope)

The entire code follows between equal sign lines:

============================================================
Set WshShell = WScript.CreateObject("WScript.Shell")

Dim Return
bWaitOnReturn = true

Return = WshShell.Run("""C:\Program Files\Novosoft\Handy Backup\hbagent.exe"" -e HB-DAVE-LOCAL-FULL-TEST1", 1, bWaitOnReturn)

wscript.echo "All done"
============================================================

Have tried all the things I can think of to get the script to wait, to no avail. Script has always run the specified program ("hbagent.exe") but has never waited for it to finish. The "All done" eyecatcher always appears prior to the compleation of the program. I've tried using the values (all with and without the quotes) "true" "TRUE", "1", and as this example shows, a variable set to the value of "true".  The hbagent has no GUI of its own but works in conjuction with a GUI, if it's open.

I've looked long and hard before asking this question and can't find any examples that I could try, and all seem to be exactly what I've tried, but without success.

Does the bWaitOnReturn value only work if there is a displayable window??

daveburrowAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

_agj_Commented:
Return = WshShell.Run("""C:\Program Files\Novosoft\Handy Backup\hbagent.exe""

there is an extra quote(") after .Run(
0
anand2kCommented:
Hi,

I was having same problem, and I got these answers from EE

Please follow this URL -
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20804957.html

I have to run PKZIP to run. But for urs this code might help.

THx
Anand
0
EDDYKTCommented:
Follows the anad2k uses shell and wait function. If it doesn't work, then it must be the program 'hbagent.exe' spawn itself so that shell and wait think your program is finished.

Try you code with wordpad.exe. Wordpad.exe has the same effect that you cannot trap the exit code.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
daveburrowAuthor Commented:
It is true, the hbagent program must spawn as the WaitForSingleObject WIN32 call also returns before the activity is complete. One suspicion I have is that the hbagent signals a different program or service to do the work. Thanks for the input.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.