IShellDispatch2.ShellExecute method
Performs a specified operation on a specified file.
Syntax
iRetVal = IShellDispatch2.ShellExecute(
sFile,
[ vArguments ],
[ vDirectory ],
[ vOperation ],
[ vShow ]
)
IShellDispatch2.ShellExecute( _
ByVal sFile As BSTR, _
[ ByVal vArguments As Variant ], _
[ ByVal vDirectory As Variant ], _
[ ByVal vOperation As Variant ], _
[ ByVal vShow As Variant ] _
) As Integer
Parameters
-
sFile [in]
-
Type: BSTR
A String that contains the name of the file on which ShellExecute will perform the action specified by vOperation.
-
vArguments [in, optional]
-
Type: Variant
A string that contains parameter values for the operation.
-
vDirectory [in, optional]
-
Type: Variant
The fully qualified path of the directory that contains the file specified by sFile. If this parameter is not specified, the current working directory is used.
-
vOperation [in, optional]
-
Type: Variant
The operation to be performed. This value is set to one of the verb strings that is supported by the file. For a discussion of verbs, see the Remarks section. If this parameter is not specified, the default operation is performed.
-
vShow [in, optional]
-
Type: Variant
A recommendation as to how the application window should be displayed initially. The application can ignore this recommendation. This parameter can be one of the following values. If this parameter is not specified, the application uses its default value.
Value Meaning - 0
Open the application with a hidden window. - 1
Open the application with a normal window. If the window is minimized or maximized, the system restores it to its original size and position. - 2
Open the application with a minimized window. - 3
Open the application with a maximized window. - 4
Open the application with its window at its most recent size and position. The active window remains active. - 5
Open the application with its window at its current size and position. - 7
Open the application with a minimized window. The active window remains active. - 10
Open the application with its window in the default state specified by the application.
Remarks
This method is implemented and accessed through the Shell.ShellExecute method.
This method is equivalent to launching one of the commands associated with a file's shortcut menu. Each command is represented by a verb string. The set of supported verbs varies from file to file. The most commonly supported verb is "open", which is also usually the default verb. Other verbs might be supported by only certain types of files. For further discussion of Shell verbs, see Launching Applications or Extending Shortcut Menus.
This method is not currently available in Microsoft Visual Basic.
Examples
The following examples show the use of ShellExecute to open Notepad. Usage is shown for JScript and VBScript.
JScript:
<script language="JScript">
function fnShellExecuteJ()
{
var objShell = new ActiveXObject("shell.application");
objShell.ShellExecute("notepad.exe", "", "", "open", 1);
}
</script>
VBScript:
<script language="VBScript">
function fnShellExecuteVB()
dim objShell
set objShell = CreateObject("shell.application")
objShell.ShellExecute "notepad.exe", "", "", "open", 1
set objShell = nothing
end function
</script>
Requirements
Requirement | Value |
---|---|
Minimum supported client |
Windows 2000 Professional, Windows XP [desktop apps only] |
Minimum supported server |
Windows Server 2003 [desktop apps only] |
Header |
|
IDL |
|
DLL |
|