Performs a specified operation on a specified file.
Syntax
IShellDispatch2.ShellExecute(sFile [, vArguments] [, vDirectory] [, vOperation] [, vShow])
Parameters
| sFile |
Required.
A String that contains the name of the file on which ShellExecute will perform the action specified by vOperation. |
| vArguments |
Optional.
A Variant that contains the parameter values for the operation. |
| vDirectory |
Optional.
A Variant that contains 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 |
Optional.
A Variant that specifies the operation to be performed. It should be 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 |
Optional.
A Variant that recommends how the window that belongs to the application that performs the operation should be displayed initially. The application can ignore this recommendation. vShow can take one of the following values. If this parameter is not specified, the application uses its default value.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.
|
Return Value
No return value.
Remarks
This method is equivalent to launching one of the commands associated with a file's shortcut menu. Each command is identified by a verb string. The supported verbs vary from file to file. The most commonly supported verb is "open", which is also usually the default verb. Others might be supported only by 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 example uses
ShellExecute to open Microsoft Notepad. Proper usage is shown for Microsoft JScript and Visual Basic Scripting Edition (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>
Applies To