System.Shell.execute method

[ The Windows Gadget Platform/Sidebar is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in subsequent versions. ]

Launches an application.

Syntax

iRetVal = System.Shell.execute(
  strFile,
  [ strArgs ],
  [ strDir ],
  [ strOperation ]
)

Parameters

strFile [in]

String that specifies a UNC path to an executable file, a file name, or a URL.

strArgs [in, optional]

If strFile specifies an executable file then String specifies the parameters to be passed to the application. For example, a UNC path such as System.Gadget.path + "\\MyFile.Txt".

Note

If strFile specifies a file name or URL, strArgs is unneccessary and should be blank, null, or an empty string.

strDir [in, optional]

String that specifies the UNC path for the default (working) directory of the executable file.

strOperation [in, optional]

String that specifies the action (or Windows Shell verb) to be performed. The set of available verbs depends on the particular file or folder.

(edit)

Opens the file specified by strArgs for editing.

(explore)

Opens the folder specified by strDir for exploring.

(find)

Opens the folder specified by strDir for searching.

(open)

Opens the file specified by strArgs.

(print)

Prints the file specified by strArgs on the default printer.

Remarks

Supplying a path to a file name (with extension) or a URL for strFile will launch the default application associated with that file name extension and load the file name specified.

Note

Alternatively, a path to a known application .exe can by supplied for strFile while strArgs, strDir, and strOperation are used to specify the rest of the file information.

strArgs, strDir, and strOperation can be assigned values in combination as required.

UNC paths should escape special characters with a '\'.

Examples

The following example demonstrates how to launch a URL.

System.Shell.execute("https://www.microsoft.com");

The following example demonstrates how to open a text file in the default application and in Notepad.

System.Shell.execute(System.Gadget.path + "\\MyFile.txt");
System.Shell.execute("Notepad.exe", "MyFile.Txt", "C:\\Users\\MyName\\", "open");

The following example demonstrates how to print a text file.

System.Shell.execute(System.Gadget.path + "\\MyFile.txt", null, null, "print");

Requirements

Minimum supported client
Windows Vista [desktop apps only]
Minimum supported server
Windows Server 2008 [desktop apps only]
End of client support
Windows 7
End of server support
Windows Server 2008
IDL
Sidebar.idl
DLL
Sidebar.Exe (version 1.00 or later)