Solved

Using WshShell.Run( ), bWaitOnReturn has no effect

Posted on 2003-12-01
4
2,740 Views
Last Modified: 2007-12-19
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??

0
Comment
Question by:daveburrow
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 7

Expert Comment

by:_agj_
ID: 9855721
Return = WshShell.Run("""C:\Program Files\Novosoft\Handy Backup\hbagent.exe""

there is an extra quote(") after .Run(
0
 
LVL 1

Assisted Solution

by:anand2k
anand2k earned 100 total points
ID: 9855777
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
 
LVL 26

Accepted Solution

by:
EDDYKT earned 200 total points
ID: 9857801
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
 

Author Comment

by:daveburrow
ID: 9865690
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question