Starts the default app associated with the specified file or URI.
Syntax
var launcher = Windows.System.Launcher;
Attributes
- MarshalingBehaviorAttribute(Standard)
- StaticAttribute(Windows.System.ILauncherStatics, NTDDI_WIN8)
- VersionAttribute(NTDDI_WIN8)
Members
The Launcher class has these types of members:
Methods
The Launcher class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.
| Method | Description |
|---|---|
| LaunchFileAsync(IStorageFile) | Starts the default app associated with the specified file. |
| LaunchFileAsync(IStorageFile, LauncherOptions) | Starts the default app associated with the specified file, using the specified options. |
| LaunchUriAsync(Uri) | Starts the default app associated with the URI scheme name for the specified URI. |
| LaunchUriAsync(Uri, LauncherOptions) | Starts the default app associated with the URI scheme name for the specified URI, using the specified options. |
Remarks
Note : This class is not agile, which means that you need to consider its threading model and marshaling behavior. For more info, see Threading and Marshaling (C++/CX) and Using Windows Runtime objects in a multithreaded environment (.NET).
Examples
This example uses LaunchFileAsync(IStorageFile) | launchFileAsync(IStorageFile) to launch a file contained in the app package.
// Path to the file in the app package to launch var imageFile = "images\\test.png"; // Get the image file from the package's image directory Windows.ApplicationModel.Package.current.installedLocation.getFileAsync(imageFile).then( function (file) { // Launch the retrieved file using the default app Windows.System.Launcher.launchFileAsync(file).then( function (success) { if (success) { // File launched } else { // File launch failed } }); });
This example uses LaunchUriAsync(Uri) | launchUriAsync(Uri) to launch a URI.
// The URI to launch var uriToLaunch = "http://www.bing.com"; // Create a Uri object from a URI string var uri = new Windows.Foundation.Uri(uriToLaunch); // Launch the URI Windows.System.Launcher.launchUriAsync(uri).then( function (success) { if (success) { // URI launched } else { // URI launch failed } });
Requirements
|
Minimum supported client | Windows 8 [Windows Store apps only] |
|---|---|
|
Minimum supported server | Windows Server 2012 [Windows Store apps only] |
|
Minimum supported phone | Windows Phone 8 |
|
Namespace |
|
|
Metadata |
|
See also
- Tasks
- How to launch the default app for a file (JavaScript)
- How to launch the default app for a file (C#/VB/C++)
- How to launch the default app for a URI (JavaScript)
- How to launch the default app for a URI (C#/VB/C++)
- Samples
- Association launching sample
- Guidelines
- Guidelines and checklist for file types and URIs
- Reference
- LauncherOptions
- LauncherUIOptions
Build date: 2/25/2013