WshShell.Run

[This is preliminary documentation and subject to change.]

The Run method creates a new process which executes strCommand with window style intWindowStyle.

Syntax

WshShell.Run (strCommand, [intWindowStype], [bWaitOnReturn])
 

Parameters

strCommand
Environment variables within the strCommand parameter are automatically expanded.
bWaitOnReturn
If bWaitOnReturn is not specified or FALSE, this method immediately returns to script execution rather than waiting on the process termination.

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, Run returns an error code of 0 (zero).

Example

' This fragment launches Notepad with the current executed script
  Set WshShell = Wscript.CreateObject("Wscript.Shell")
  WshShell.Run ("notepad " & Wscript.ScriptFullName)
  WshShell.Run ("%windir%\notepad" & Wscript.ScriptFullName)

' This fragment returns the error code from the executed application
  Return = WshShell.Run("notepad " & Wscript.ScriptFullName, 1, TRUE)

© 1997 Microsoft Corporation. All rights reserved. Terms of Use.