×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Shell another process and wait.

Shell another process and wait.

Shell another process and wait.

(OP)
Using VBScript, how can I run another exe (shell out another process) and wait for that process to finish? Thanks.

- Jeff Marler

RE: Shell another process and wait.

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

RE: Shell another process and wait.

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

RE: Shell another process and wait.

(OP)
That was exactly what I needed! Thanks!

- Jeff Marler

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close