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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shell another process and wait. 1

Status
Not open for further replies.

jmarler

Programmer
Jan 29, 2001
679
US
Using VBScript, how can I run another exe (shell out another process) and wait for that process to finish? Thanks.
- Jeff Marler B-)
 
In Win Script Host, Shell object supports Run method. Would that suit your need?

Ref : WSH documentation

Run Method [excerpt]

Description
Creates a new process that executes strCommand.

Syntax
object.Run (strCommand, [intWindowStyle], [bWaitOnReturn])

Parameters

Part : Description

object : WshShell object.

strCommand : Environment variables within the strCommand parameter are automatically expanded.

intWindowStyle : Optional. Sets the window style of the program being run.

bWaitOnReturn : Optional. If bWaitOnReturn is not specified or FALSE, immediately returns to script execution rather than waiting for the process to end.

If bWaitOnReturn is set to TRUE, the Run method returns any error code returned by the application.

If bWaitOnReturn is not specified or is FALSE, the Run method returns an error code of 0 (zero).

The following example executes notepad application and waits until closed:

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "notepad " & WScript.ScriptFullName, 1, TRUE

 
errata :
Have left a couple of words out in the example above.

The following example executes notepad, which loads the script where the lines actually are written, and waits until it is closed.

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "notepad " & WScript.ScriptFullName, 1, TRUE

Open a blank document, of course, is :

WshShell.Run "notepad", 1, TRUE
 
That was exactly what I needed! Thanks! - Jeff Marler B-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top