Solved

Using WshShell.Run( ), bWaitOnReturn has no effect

Posted on 2003-12-01
4
2,701 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
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

705 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now