Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Another WshShell.Run Problem

Status
Not open for further replies.

000Steve000

IS-IT--Management
Jul 9, 2004
50
GB
Why does -
Return = WshShell.Run("notepad", 1, true)
return a '0' and wait for notepad to close before executing the next line of script, but -
Return = WshShell.Run("explorer", 1, true)
return a 1 and continues the rest of the script without waiting for explorer to end? Explorer is not the only program I have found that allows WshShell.Run to apparently ignore the WAIT.
 
Perhaps because Explorer is heavily multi-threaded ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
A guess the supplementary question is does anyone know another way of pausing execution of a script until another program ends?
 
Have you tried the WshShell.Exec method and the WshScriptExec.Status property ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks for the tip, I had not previously used the .status property. However, I tried:

Dim WshShell, oExec
Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("calc")
Do While oExec.Status = 0
WScript.Sleep 100
Loop
WScript.Echo oExec.Status

Which worked, but when I substituted explorer for calc it, once again, didn't wait (and returned a '1').
 
Hello 000Steve000,

If you want hard enough to launch a "explorer" listview and wait for that particular instance, then do this.
Code:
Return = WshShell.Run("iexplorer c:\", 1, true)
The observed behavior is related to the shell and threading. The explorer as a process, the shell, is absolutely unique. Hence, it failed (return 0). But, nonetheless, it succeeds as well as a thread is spawned under the master.

regards - tsuji
 
Correction:

I meant
Code:
Return = WshShell.Run("iexplore c:\", 1, true)
The surplus "r" is the result of cut-and-paste not cleaning up!

- tsuji
 
Thanks tsuji

Sorry if I misled you, Explorer was an example that I found. I was actually trying to run the Oracle database installer as part of an auto-build script for an Oracle Db. The script takes a dump of an Oracle V7.3.4 db before de-installing a VB front end and then the Oracle V7.3.4 application. The problem appears at the next stage which launches Oracle installer for an Oracle 9.2 db. It is this program that the WshShell.Run fails to wait for.

 
000Steve000,

It would be the same logic. Even though explorer being absolutely unique in many aspects, it is not unusual other commandline leads to the same behaviour. Installer, cpl, office application are known to provoke the same.

A way to investigate it is to launch a process viewer and watch how process is created. In some cases, if you launch process A. The process A itself will launch in fact process B and retire itself. In this case, you may have similar phenomenon. If it is under this category, then you have to discover which executable corresponds to having process B, and you .run that executable instead.

- tsuji

ps. My 1st posting "(return 0)" should be read as "(return<>0)". Just put the record straight.
 
I think the Oracle install is written in java, so you may be able to monitor java processes.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Yes it is Java, I will try your suggestion on Monday.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top