Solved

Using WshShell.Run( ), bWaitOnReturn has no effect

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

776 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