O'Reilly logo

VB.NET Language in a Nutshell, Second Edition by Steven Roman PhD, Paul Lomax, Ron Petrusha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

Shell Function

Class

Microsoft.VisualBasic.Interaction

Syntax

Shell(pathname[,style][, Wait][, Timeout] )
pathname (required; String)

Name of the program to execute

style (optional; AppWinStyle enumeration)

The style of window and whether it receives the focus; see Section

Wait (optional; Boolean)

Boolean indicating whether to wait for the pathname application to finish execution before continuing execution of subsequent code

Timeout (optional; Integer)

If Wait is True, number of milliseconds to wait for the pathname application to terminate before the Shell function times out

Return Value

An Integer representing the Process ID, or 0

Description

Launches another application and, if successful, returns that application’s task ID

Rules at a Glance

  • pathname can include a drive letter. If a drive letter is not included in pathname, the current drive is assumed.

  • pathname can include a folder name. You can use either a fully qualified path (i.e., starting from the root directory) or a relative path (i.e., starting from the current directory). If the folder name is not included in pathname, the current folder is assumed.

  • pathname can include any command-line arguments and switches required by the application. For example:

    Shell("notepad.exe c:\data.txt", AppWinStyle.NormalFocus)

    launches Notepad, which loads the file data.txt.

  • Visual Basic includes the following intrinsic constants for setting the style argument:

    AppWinStyle.Hide Value: 0

    New application window is hidden

    Focus: New application ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required