Shell.ShellExecute method
Performs a specified operation on a specified file.
Syntax
iRetVal = Shell.ShellExecute( sFile, [ vArguments ], [ vDirectory ], [ vOperation ], [ vShow ] )
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.
Remarks
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
Requirements
|
Minimum supported client | Windows 2000 Professional, Windows XP [desktop apps only] |
|---|---|
|
Minimum supported server | Windows Server 2003 [desktop apps only] |
|
Header |
|
|
IDL |
|
|
DLL |
|
Send comments about this topic to Microsoft
Build date: 11/28/2012
