Visual Basic – WshShell.Run

--> (Word) --> (PDF) --> (Epub)
This article has been published [fromdate]

Method: WshShell.Run


WshShell.Run strCommand [,intWindowStyle] [,bWaitOnReturn]

The Run method creates a new process and runs the command specified by strCommand.

  • The optional parameter intWindowStyle is used to set the window style of the program being run.
  • If the optional parameter bWaitOnReturn is set to True (default is False), then Run will return the return value returned by strCommand.
  • Otherwise it returns 0. Also, if bWaitOnReturn is set to True, then the script will suspend its execution until strCommand finishes.

The following table shows the available settings for intWindowStyle.

shellcodes

The following VBScript code starts Notepad using the [gs script]'s own full path name as the parameter for Notepad.

Code:

Set WshShell = WScript.CreateObject("WScript.Shell")
  
intReturn = WshShell.Run("notepad " & WScript.ScriptFullName, 1, TRUE)
WshShell.Popup "Notepad is now closed."
SOURCE

LINK (Devguru.com)

LANGUAGE
ENGLISH