Name
Shell Function
Class
Microsoft.VisualBasic.Interaction
Syntax
Shell(pathname[,style][,Wait][,Timeout] )
-
pathname(required; String) Name of the program to execute
-
style(optional;AppWinStyleenumeration) The style of window and whether it receives the focus; see Section
-
Wait(optional; Boolean) Boolean indicating whether to wait for the
pathnameapplication to finish execution before continuing execution of subsequent code-
Timeout(optional; Integer) If
WaitisTrue, number of milliseconds to wait for thepathnameapplication 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
pathnamecan include a drive letter. If a drive letter is not included inpathname, the current drive is assumed.pathnamecan 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 inpathname, the current folder is assumed.pathnamecan 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
styleargument:-
AppWinStyle.HideValue: 0 New application window is hidden
Focus: New application ...
-
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access