Launcher Launcher Launcher Launcher Class
Definition
Starts the default app associated with the specified file or URI.
public : static class Launcherpublic static class LauncherPublic Static Class Launcher// You can use this class in JavaScript.
- Attributes
| Device family |
Windows 10 (introduced v10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v1)
|
Examples
Launch a file contained in the app packageThis 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
}
});
});
async void DefaultLaunch()
{
// Path to the file in the app package to launch
string imageFile = @"images\test.png";
var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(imageFile);
if (file != null)
{
// Launch the retrieved file
var success = await Windows.System.Launcher.LaunchFileAsync(file);
if (success)
{
// File launched
}
else
{
// File launch failed
}
}
else
{
// Could not find file
}
}
async Sub DefaultLaunch()
' Path to the file in the app package to launch
Dim imageFile = "images\test.png"
Dim file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(imageFile)
If file IsNot Nothing Then
' Launch the retrieved file
Dim success = await Windows.System.Launcher.LaunchFileAsync(file)
If success Then
' File launched
Else
' File launch failed
End If
Else
' Could not find file
End If
End Sub
void MainPage::DefaultLaunch()
{
auto installFolder = Windows::ApplicationModel::Package::Current->InstalledLocation;
concurrency::task<Windows::Storage::StorageFile^> getFileOperation(installFolder->GetFileAsync("images\\test.png"));
getFileOperation.then([](Windows::Storage::StorageFile^ file)
{
if (file != nullptr)
{
// Launch the retrieved file
concurrency::task<bool> launchFileOperation(Windows::System::Launcher::LaunchFileAsync(file));
launchFileOperation.then([](bool success)
{
if (success)
{
// File launched
}
else
{
// File launch failed
}
});
}
else
{
// Could not find file
}
});
}
Launch a URIThis 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
}
});
// The URI to launch
string uriToLaunch = @"http://www.bing.com";
// Create a Uri object from a URI string
var uri = new Uri(uriToLaunch);
// Launch the URI
async void DefaultLaunch()
{
// Launch the URI
var success = await Windows.System.Launcher.LaunchUriAsync(uri);
if (success)
{
// URI launched
}
else
{
// URI launch failed
}
}
' The URI to launch
Dim uri As New Uri("http://www.bing.com")
async Sub DefaultLaunch()
' Launch the URI
Dim success = await Windows.System.Launcher.LaunchUriAsync(uri)
If success Then
' URI launched
Else
' URI launch failed
End If
End Sub
// The URI to launch
auto uri = ref new Windows::Foundation::Uri("http://www.bing.com");
void MainPage::DefaultLaunch()
{
// Launch the URI
concurrency::task<bool> launchUriOperation(Windows::System::Launcher::LaunchUriAsync(uri));
launchUriOperation.then([](bool success)
{
if (success)
{
// URI launched
}
else
{
// URI launch failed
}
});
}
Launch with a warning dialogCall launchUriAsync(Uri, LauncherOptions) to launch a URI with a warning. Use the treatAsUntrusted property to indicate that the system should display a warning.
Note
For Windows app using JavaScript, call preventDefault in your event handler if the treatAsUntrusted property is set and you are using an a element to launch the URI.
function linkClickHandler(eventInfo) {
var link = eventInfo.target;
if (eventInfo.srcElement && (
(eventInfo.type === "click") ||
(eventInfo.type === "keydown" && (
eventInfo.keyCode === WinJS.Utilities.Key.enter ||
eventInfo.keyCode === WinJS.Utilities.Key.space)))) {
eventInfo.preventDefault();
if (link.href.indexOf("ms-appx") > -1) {
WinJS.Navigation.navigate(link.href);
}
else if (link.href.indexOf("http") > -1) {
// Create a Uri object from a URI string
var uri = new Windows.Foundation.Uri(link.href);
var options = new Windows.System.LauncherOptions();
// Launch the URI with a warning prompt
options.treatAsUntrusted = true;
// Launch the URI
Windows.System.Launcher.launchUriAsync(uri, options).then(
function (success) {
if (success) {
// URI launched
} else {
// URI launch failed
}
});
}
}
}
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).
Methods
FindAppUriHandlersAsync(Uri) FindAppUriHandlersAsync(Uri) FindAppUriHandlersAsync(Uri) FindAppUriHandlersAsync(Uri)
Enumerate the Uniform Resource Identifiers (URI) handlers on the device.
public : static IAsyncOperation<IVectorView<AppInfo>> FindAppUriHandlersAsync(Uri uri)public static IAsyncOperation<IReadOnlyList<AppInfo>> FindAppUriHandlersAsync(Uri uri)Public Static Function FindAppUriHandlersAsync(uri As Uri) As IAsyncOperation( Of IReadOnlyListAppInfo )// You can use this method in JavaScript.
- uri
- Uri Uri Uri Uri
The Uri that you want to find handlers for.
A list of AppInfo objects representing each application that handles the specified http(s) URI.
| Device family |
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v3)
|
Remarks
This API may also be called from Windows desktop application but does not return Windows desktop application.
FindFileHandlersAsync(String) FindFileHandlersAsync(String) FindFileHandlersAsync(String) FindFileHandlersAsync(String)
Enumerate the file handlers on the device.
public : static IAsyncOperation<IVectorView<AppInfo>> FindFileHandlersAsync(PlatForm::String extension)public static IAsyncOperation<IReadOnlyList<AppInfo>> FindFileHandlersAsync(String extension)Public Static Function FindFileHandlersAsync(extension As String) As IAsyncOperation( Of IReadOnlyListAppInfo )// You can use this method in JavaScript.
- extension
- PlatForm::String String String String
The file extension that you want to find handlers for. For example, ".bat". Include the leading period '.'.
A list of AppInfo s for each application that handles the specified file extension.
Remarks
This API may also be called from Windows desktop application but does not return Windows desktop application.
FindUriSchemeHandlersAsync(String) FindUriSchemeHandlersAsync(String) FindUriSchemeHandlersAsync(String) FindUriSchemeHandlersAsync(String)
Enumerate the scheme handlers on the device.
public : static IAsyncOperation<IVectorView<AppInfo>> FindUriSchemeHandlersAsync(PlatForm::String scheme)public static IAsyncOperation<IReadOnlyList<AppInfo>> FindUriSchemeHandlersAsync(String scheme)Public Static Function FindUriSchemeHandlersAsync(scheme As String) As IAsyncOperation( Of IReadOnlyListAppInfo )// You can use this method in JavaScript.
- scheme
- PlatForm::String String String String
The scheme name that you find to find handlers for. For example, "ms-lens".
A list of AppInfo s for each application that handles the specified scheme.
Remarks
This API may also be called from Windows desktop application but does not return Windows desktop application.
- See Also
FindUriSchemeHandlersAsync(String, LaunchQuerySupportType) FindUriSchemeHandlersAsync(String, LaunchQuerySupportType) FindUriSchemeHandlersAsync(String, LaunchQuerySupportType) FindUriSchemeHandlersAsync(String, LaunchQuerySupportType)
Enumerate the scheme handlers on the device.
public : static IAsyncOperation<IVectorView<AppInfo>> FindUriSchemeHandlersAsync(PlatForm::String scheme, LaunchQuerySupportType launchQuerySupportType)public static IAsyncOperation<IReadOnlyList<AppInfo>> FindUriSchemeHandlersAsync(String scheme, LaunchQuerySupportType launchQuerySupportType)Public Static Function FindUriSchemeHandlersAsync(scheme As String, launchQuerySupportType As LaunchQuerySupportType) As IAsyncOperation( Of IReadOnlyListAppInfo )// You can use this method in JavaScript.
- scheme
- PlatForm::String String String String
The scheme name that you find to find handlers for. For example, "ms-lens".
- launchQuerySupportType
- LaunchQuerySupportType LaunchQuerySupportType LaunchQuerySupportType LaunchQuerySupportType
Filter the list of handlers by whether they can be launched for results or not.
A list of AppInfo s for each application that handles the specified scheme.
Remarks
This API may also be called from Windows desktop application but does not return Windows desktop application.
- See Also
LaunchFileAsync(IStorageFile) LaunchFileAsync(IStorageFile) LaunchFileAsync(IStorageFile) LaunchFileAsync(IStorageFile)
Starts the default app associated with the specified file.
public : static IAsyncOperation<PlatForm::Boolean> LaunchFileAsync(IStorageFile file)public static IAsyncOperation<bool> LaunchFileAsync(IStorageFile file)Public Static Function LaunchFileAsync(file As IStorageFile) As IAsyncOperation( Of bool )// You can use this method in JavaScript.
The file.
The launch operation.
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\ est.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
}
});
});
async void DefaultLaunch()
{
// Path to the file in the app package to launch
string imageFile = @"images est.png";
var file = wait Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(imageFile);
if (file != null)
{
// Launch the retrieved file
var success = await Windows.System.Launcher.LaunchFileAsync(file);
if (success)
{
// File launched
}
else
{
// File launch failed
}
}
else
{
// Could not find file
}
}
async Sub DefaultLaunch()
' Path to the file in the app package to launch
Dim imageFile = "images est.png"
Dim file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(imageFile)
If file IsNot Nothing Then
' Launch the retrieved file
Dim success = await Windows.System.Launcher.LaunchFileAsync(file)
If success Then
' File launched
Else
' File launch failed
End If
Else
' Could not find file
End If
End Sub
void MainPage::DefaultLaunch()
{
auto installFolder = Windows::ApplicationModel::Package::Current->InstalledLocation;
concurrency::task<Windows::Storage::StorageFile^> getFileOperation(installFolder->GetFileAsync("images\ est.png"));
getFileOperation.then([](Windows::Storage::StorageFile^ file)
{
if (file != nullptr)
{
// Launch the retrieved file
concurrency::task<bool> launchFileOperation(Windows::System::Launcher::LaunchFileAsync(file));
launchFileOperation.then([](bool success)
{
if (success)
{
// File launched
}
else
{
// File launch failed
}
});
}
else
{
// Could not find file
}
});
}
Remarks
The calling app must be visible to the user when the API is invoked.
This API must be called from an ASTA thread (also known as a UI thread).
This API also imposes several restrictions on what types of files it can launch. Many file types that contain executable code, for example .exe, .msi, and .js files, are blocked from launching. This restriction protects users from potentially malicious files that could modify the system.
When the launch fails for any of the above reasons, the API succeeds and returns FALSE from its asynchronous operation. Since it has no ability to query whether the above restrictions apply to the current launch, the calling app should not assume that the launch succeeded, and should provide fallback mechanism in case it failed. A possible solution would be to ask the user to save the file and direct the user to open it in the desktop.
To enable the user to choose an app instead of launching the default app, set the LauncherOptions.DisplayApplicationPicker | displayApplicationPicker property.
To display a warning that the file is potentially unsafe, set the LauncherOptions.TreatAsUntrusted | treatAsUntrusted property.
The file is passed to the associated app. If the associated app is a desktop app, the file is passed using shell execution mechanisms.
- See Also
-
LaunchFileAsync(IStorageFile, LauncherOptions) LaunchFileAsync(IStorageFile, LauncherOptions) LaunchFileAsync(IStorageFile, LauncherOptions) LaunchFileAsync(IStorageFile, LauncherOptions)
Starts the default app associated with the specified file, using the specified options.
public : static IAsyncOperation<PlatForm::Boolean> LaunchFileAsync(IStorageFile file, LauncherOptions options)public static IAsyncOperation<bool> LaunchFileAsync(IStorageFile file, LauncherOptions options)Public Static Function LaunchFileAsync(file As IStorageFile, options As LauncherOptions) As IAsyncOperation( Of bool )// You can use this method in JavaScript.
The file.
The launch options for the app.
The launch operation.
Examples
Call the Launcher.LaunchFileAsync(IStorageFile, LauncherOptions) | launchFileAsync(IStorageFile, LauncherOptions) method with LauncherOptions.DisplayApplicationPicker | displayApplicationPicker set to true to launch the app that the user selects for the file from the Open With dialog box.
// Path to the file in the app package to launch
var imageFile = "images\ est.png";
// Get the image file from the package's image directory
Windows.ApplicationModel.Package.current.installedLocation.getFileAsync(imageFile).then(
function (file) {
// Set the show picker option
var options = new Windows.System.LauncherOptions();
options.displayApplicationPicker = true;
// Launch the retrieved file using the selected app
Windows.System.Launcher.launchFileAsync(file, options).then(
function (success) {
if (success) {
// File launched
} else {
// File launch failed
}
});
});
async void DefaultLaunch()
{
// Path to the file in the app package to launch
string imageFile = @"images est.png";
var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(imageFile);
if (file != null)
{
// Set the option to show the picker
var options = new Windows.System.LauncherOptions();
options.DisplayApplicationPicker = true;
// Launch the retrieved file
bool success = await Windows.System.Launcher.LaunchFileAsync(file, options);
if (success)
{
// File launched
}
else
{
// File launch failed
}
}
else
{
// Could not find file
}
}
async Sub DefaultLaunch()
' Path to the file in the app package to launch
Dim imageFile = "images est.png"
Dim file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(imageFile)
If file IsNot Nothing Then
' Set the option to show the picker
Dim options = Windows.System.LauncherOptions()
options.DisplayApplicationPicker = True
' Launch the retrieved file
Dim success = await Windows.System.Launcher.LaunchFileAsync(file, options)
If success Then
' File launched
Else
' File launch failed
End If
Else
' Could not find file
End If
End Sub
void MainPage::DefaultLaunch()
{
auto installFolder = Windows::ApplicationModel::Package::Current->InstalledLocation;
concurrency::task<Windows::Storage::StorageFile^> getFileOperation(installFolder->GetFileAsync("images\ est.png"));
getFileOperation.then([](Windows::Storage::StorageFile^ file)
{
if (file != nullptr)
{
// Set the option to show the picker
auto launchOptions = ref new Windows::System::LauncherOptions();
launchOptions->DisplayApplicationPicker = true;
// Launch the retrieved file
concurrency::task<bool> launchFileOperation(Windows::System::Launcher::LaunchFileAsync(file, launchOptions));
launchFileOperation.then([](bool success)
{
if (success)
{
// File launched
}
else
{
// File launch failed
}
});
}
else
{
// Could not find file
}
});
}
Remarks
The calling app must be visible to the user when the API is invoked.
This API must be called from within an ASTA thread (also known as a UI thread).
This API also imposes several restrictions on what types of files it can launch. Many file types that contain executable code, for example .exe, .msi, and .js files, are blocked from launching. This restriction protects users from potentially malicious files that could modify the system.
When the launch fails for any of the above reasons, the API succeeds and returns FALSE from its asynchronous operation. Since it has no ability to query whether the above restrictions apply to the current launch, the calling app should not assume that the launch succeeded, and should provide fallback mechanism in case it failed. A possible solution would be to ask the user to save the file and direct the user to open it in the desktop.
To enable the user to choose an app instead of launching the default app, set the LauncherOptions.DisplayApplicationPicker | displayApplicationPicker property.
To display a warning that the file is potentially unsafe, set the LauncherOptions.TreatAsUntrusted | treatAsUntrusted property.
The file is passed to the associated app. If the associated app is a desktop app, the file is passed using shell execution mechanisms.
- See Also
-
LaunchFolderAsync(IStorageFolder) LaunchFolderAsync(IStorageFolder) LaunchFolderAsync(IStorageFolder) LaunchFolderAsync(IStorageFolder)
Launches File Explorer and displays the contents of the specified folder.
public : static IAsyncOperation<PlatForm::Boolean> LaunchFolderAsync(IStorageFolder folder)public static IAsyncOperation<bool> LaunchFolderAsync(IStorageFolder folder)Public Static Function LaunchFolderAsync(folder As IStorageFolder) As IAsyncOperation( Of bool )// You can use this method in JavaScript.
The folder to display in File Explorer.
The result of the operation.
Remarks
This API must be called from within an ASTA thread (also known as a UI thread).
- See Also
LaunchFolderAsync(IStorageFolder, FolderLauncherOptions) LaunchFolderAsync(IStorageFolder, FolderLauncherOptions) LaunchFolderAsync(IStorageFolder, FolderLauncherOptions) LaunchFolderAsync(IStorageFolder, FolderLauncherOptions)
Launches File Explorer with the specified options and displays the contents of the specified folder.
public : static IAsyncOperation<PlatForm::Boolean> LaunchFolderAsync(IStorageFolder folder, FolderLauncherOptions options)public static IAsyncOperation<bool> LaunchFolderAsync(IStorageFolder folder, FolderLauncherOptions options)Public Static Function LaunchFolderAsync(folder As IStorageFolder, options As FolderLauncherOptions) As IAsyncOperation( Of bool )// You can use this method in JavaScript.
The folder to display in File Explorer.
Options that specify the amount of screen space that File Explorer fills, and the list of items to select in the specified folder.
The result of the operation.
Remarks
This API must be called from within an ASTA thread (also known as a UI thread).
- See Also
LaunchUriAsync(Uri) LaunchUriAsync(Uri) LaunchUriAsync(Uri) LaunchUriAsync(Uri)
Starts the default app associated with the URI scheme name for the specified URI.
public : static IAsyncOperation<PlatForm::Boolean> LaunchUriAsync(Uri uri)public static IAsyncOperation<bool> LaunchUriAsync(Uri uri)Public Static Function LaunchUriAsync(uri As Uri) As IAsyncOperation( Of bool )// You can use this method in JavaScript.
- uri
- Uri Uri Uri Uri
The URI.
Returns true if the default app for the URI scheme was launched; false otherwise.
Examples
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
}
});
// The URI to launch
string uriToLaunch = @"http://www.bing.com";
// Create a Uri object from a URI string
var uri = new Uri(uriToLaunch);
// Launch the URI
async void DefaultLaunch()
{
// Launch the URI
var success = await Windows.System.Launcher.LaunchUriAsync(uri);
if (success)
{
// URI launched
}
else
{
// URI launch failed
}
}
' The URI to launch
Dim uri As New Uri("http://www.bing.com")
async Sub DefaultLaunch()
' Launch the URI
Dim success = await Windows.System.Launcher.LaunchUriAsync(uri)
If success Then
' URI launched
Else
' URI launch failed
End If
End Sub
// The URI to launch
auto uri = ref new Windows::Foundation::Uri("http://www.bing.com");
void MainPage::DefaultLaunch()
{
// Launch the URI
concurrency::task<bool> launchUriOperation(Windows::System::Launcher::LaunchUriAsync(uri));
launchUriOperation.then([](bool success)
{
if (success)
{
// URI launched
}
else
{
// URI launch failed
}
});
}
Remarks
Unless you are calling this API from a Windows desktop application, this API must be called from within an ASTA thread (also known as the UI thread).
This API may also be called from a Windows desktop application.
This API launches the default app for the scheme whether it be a Universal Windows Platform (UWP) app or Windows desktop application.
The calling app must be visible to the user when the API is invoked.
You must specify the privateNetworkClientServer capability in the manifest in order to launch intranet URIs, for example a file:/// URI pointing to a network location.
You cannot use this method to launch a URI in the local zone. For example, apps cannot use the file:/// protocol to access files on the local computer. Instead, you must use the Storage APIs to access files.
When the launch fails for any of the above reasons, the API will succeed and return FALSE from its asynchronous operation.
To enable the user to choose an app instead of launching the default app, set the LauncherOptions.DisplayApplicationPicker | displayApplicationPicker property.
To display a warning that the URI is potentially unsafe, set the LauncherOptions.TreatAsUntrusted | treatAsUntrusted property.
The URI is passed to the associated app. If the associated app is a desktop app, the URI is passed using shell execution mechanisms.
LaunchUriAsync(Uri, LauncherOptions) LaunchUriAsync(Uri, LauncherOptions) LaunchUriAsync(Uri, LauncherOptions) LaunchUriAsync(Uri, LauncherOptions)
Starts the default app associated with the URI scheme name or the one specified by the ContentType for the specified URI, using the specified options.
public : static IAsyncOperation<PlatForm::Boolean> LaunchUriAsync(Uri uri, LauncherOptions options)public static IAsyncOperation<bool> LaunchUriAsync(Uri uri, LauncherOptions options)Public Static Function LaunchUriAsync(uri As Uri, options As LauncherOptions) As IAsyncOperation( Of bool )// You can use this method in JavaScript.
- uri
- Uri Uri Uri Uri
The URI.
The launch options for the app.
Returns true if the default app for the URI scheme was launched; false otherwise.
Examples
This sample uses LaunchUriAsync(Uri, LauncherOptions) | launchUriAsync(Uri, LauncherOptions) to launch a URI with a warning. The TreatAsUntrusted | treatAsUntrusted property indicates that the system should display a warning.
Note
For Windows app using JavaScript, call preventDefault in your event handler if the treatAsUntrusted property is set and you are using an a element to launch the 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 with a warning prompt
var options = new Windows.System.LauncherOptions();
options.treatAsUntrusted = true;
Windows.System.Launcher.launchUriAsync(uri, options).then(
function (success) {
if (success) {
// URI launched
} else {
// URI launch failed
}
});
// The URI to launch
string uriToLaunch = @"http://www.bing.com";
var uri = new Uri(uriToLaunch);
async void DefaultLaunch()
{
// Set the option to show a warning
var options = new Windows.System.LauncherOptions();
options.TreatAsUntrusted = true;
// Launch the URI with a warning prompt
var success = await Windows.System.Launcher.LaunchUriAsync(uri, options);
if (success)
{
// URI launched
}
else
{
// URI launch failed
}
}
' The URI to launch
Dim uri As New Uri("http://www.bing.com")
async Sub DefaultLaunch()
' Set the option to show a warning
Dim options = Windows.System.LauncherOptions()
options.TreatAsUntrusted = True
' Launch the URI with a warning prompt
Dim success = await Windows.System.Launcher.LaunchUriAsync(uri, options)
If success Then
' URI launched
Else
' URI launch failed
End If
End Sub
// The URI to launch
auto uri = ref new Windows::Foundation::Uri("http://www.bing.com");
void MainPage::DefaultLaunch()
{
// Set the option to show a warning
auto launchOptions = ref new Windows::System::LauncherOptions();
launchOptions->TreatAsUntrusted = true;
// Launch the URI with a warning prompt
concurrency::task<bool> launchUriOperation(Windows::System::Launcher::LaunchUriAsync(uri, launchOptions));
launchUriOperation.then([](bool success)
{
if (success)
{
// URI launched
}
else
{
// URI launch failed
}
});
}
Remarks
Unless you are calling this API from a Windows desktop application, this API must be called from within an ASTA thread (also known as the UI thread).
This API may also be called from a Windows desktop application.
This API launches the default app for the scheme whether it be a Universal Windows Platform (UWP) app or Windows desktop application.
The calling app must be visible to the user when this API is invoked.
Unless you are calling this API from a Windows desktop application, this API must be called from within an ASTA thread (also known as a UI thread).
You must specify the privateNetworkClientServer capability in the manifest in order to launch intranet URIs, for example a file:/// URI pointing to a network location.
You cannot use this method to launch a URI in the local zone. For example, apps cannot use the file:/// protocol to access files on the local computer. Instead, you must use the Storage APIs to access files.
The content type is used to compute a file extension, from the extension the default app is chosen. For example a content type value of ""application/vnd.ms-word.document.12"" is mapped to ".docx" and then the default application for ".docx" is launched. For example:
// this specifies the file type, which is used to bind to Word.
launcherOptions.ContentType = "application/vnd.ms-word.document.12";
// and then this launches the file using the application
Launcher.LaunchUriAsync("http://www.cloud.com/file.docx", options);
When the launch fails for any of the above reasons, the API will succeed and return FALSE from its asynchronous operation.
To enable the user to choose an app instead of launching the default app, set the LauncherOptions.DisplayApplicationPicker | displayApplicationPicker property.
To display a warning that the URI is potentially unsafe, set the LauncherOptions.TreatAsUntrusted | treatAsUntrusted property.
The URI is passed to the associated app. If the associated app is a desktop app, the URI is passed using shell execution mechanisms.
LaunchUriAsync(Uri, LauncherOptions, ValueSet) LaunchUriAsync(Uri, LauncherOptions, ValueSet) LaunchUriAsync(Uri, LauncherOptions, ValueSet) LaunchUriAsync(Uri, LauncherOptions, ValueSet)
Starts the default app associated with the URI scheme name for the specified URI, using the specified options and input data.
public : static IAsyncOperation<PlatForm::Boolean> LaunchUriAsync(Uri uri, LauncherOptions options, ValueSet inputData)public static IAsyncOperation<bool> LaunchUriAsync(Uri uri, LauncherOptions options, ValueSet inputData)Public Static Function LaunchUriAsync(uri As Uri, options As LauncherOptions, inputData As ValueSet) As IAsyncOperation( Of bool )// You can use this method in JavaScript.
- uri
- Uri Uri Uri Uri
The URI.
The launch options for the app.
The input data for the app.
Important
The amount of data that can be transferred must not exceed 100 KB.
Returns true if the default app for the URI scheme was launched; false otherwise.
Remarks
Unless you are calling this API from a Windows desktop application, this API must be called from within an ASTA thread (also known as the UI thread).
This API may also be called from a Windows desktop application.
This API launches the default app for the scheme whether it be a Universal Windows Platform (UWP) app or Windows desktop application.
- See Also
LaunchUriForResultsAsync(Uri, LauncherOptions) LaunchUriForResultsAsync(Uri, LauncherOptions) LaunchUriForResultsAsync(Uri, LauncherOptions) LaunchUriForResultsAsync(Uri, LauncherOptions)
Asynchronously starts the default app associated with the URI scheme name for the specified URI, using the specified options.
public : static IAsyncOperation<LaunchUriResult> LaunchUriForResultsAsync(Uri uri, LauncherOptions options)public static IAsyncOperation<LaunchUriResult> LaunchUriForResultsAsync(Uri uri, LauncherOptions options)Public Static Function LaunchUriForResultsAsync(uri As Uri, options As LauncherOptions) As IAsyncOperation( Of LaunchUriResult )// You can use this method in JavaScript.
- uri
- Uri Uri Uri Uri
The Uri to launch.
The launch options.
When this method completes, it returns the results of the launch.
Remarks
Launching an app for results allows you to launch an app from another app and exchange data between the two.
This API must be called from within an ASTA thread (also known as a UI thread).
- See Also
LaunchUriForResultsAsync(Uri, LauncherOptions, ValueSet) LaunchUriForResultsAsync(Uri, LauncherOptions, ValueSet) LaunchUriForResultsAsync(Uri, LauncherOptions, ValueSet) LaunchUriForResultsAsync(Uri, LauncherOptions, ValueSet)
Asynchronously starts the default app associated with the URI scheme name for the specified URI, using the specified options and input data.
public : static IAsyncOperation<LaunchUriResult> LaunchUriForResultsAsync(Uri uri, LauncherOptions options, ValueSet inputData)public static IAsyncOperation<LaunchUriResult> LaunchUriForResultsAsync(Uri uri, LauncherOptions options, ValueSet inputData)Public Static Function LaunchUriForResultsAsync(uri As Uri, options As LauncherOptions, inputData As ValueSet) As IAsyncOperation( Of LaunchUriResult )// You can use this method in JavaScript.
- uri
- Uri Uri Uri Uri
The Uri to launch.
The launch options.
When this method completes, it returns the results of the launch.
Remarks
Launching an app for results allows you to launch an app from another app and exchange data between the two.
This API must be called from within an ASTA thread (also known as a UI thread).
- See Also
LaunchUriForResultsForUserAsync(User, Uri, LauncherOptions) LaunchUriForResultsForUserAsync(User, Uri, LauncherOptions) LaunchUriForResultsForUserAsync(User, Uri, LauncherOptions) LaunchUriForResultsForUserAsync(User, Uri, LauncherOptions)
Asynchronously starts the default app associated with the URI scheme name for the specified URI using the specified options, and provides a specific User as context.
public : static IAsyncOperation<LaunchUriResult> LaunchUriForResultsForUserAsync(User user, Uri uri, LauncherOptions options)public static IAsyncOperation<LaunchUriResult> LaunchUriForResultsForUserAsync(User user, Uri uri, LauncherOptions options)Public Static Function LaunchUriForResultsForUserAsync(user As User, uri As Uri, options As LauncherOptions) As IAsyncOperation( Of LaunchUriResult )// You can use this method in JavaScript.
- uri
- Uri Uri Uri Uri
The Uri.
The launch options.
When this method completes, it returns the results of the launch.
| Device family |
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v3)
|
- See Also
LaunchUriForResultsForUserAsync(User, Uri, LauncherOptions, ValueSet) LaunchUriForResultsForUserAsync(User, Uri, LauncherOptions, ValueSet) LaunchUriForResultsForUserAsync(User, Uri, LauncherOptions, ValueSet) LaunchUriForResultsForUserAsync(User, Uri, LauncherOptions, ValueSet)
Asynchronously starts the default app associated with the URI scheme name for the specified URI using the specified options and input data, and provides a specific User as context.
public : static IAsyncOperation<LaunchUriResult> LaunchUriForResultsForUserAsync(User user, Uri uri, LauncherOptions options, ValueSet inputData)public static IAsyncOperation<LaunchUriResult> LaunchUriForResultsForUserAsync(User user, Uri uri, LauncherOptions options, ValueSet inputData)Public Static Function LaunchUriForResultsForUserAsync(user As User, uri As Uri, options As LauncherOptions, inputData As ValueSet) As IAsyncOperation( Of LaunchUriResult )// You can use this method in JavaScript.
- uri
- Uri Uri Uri Uri
The Uri.
The launch options.
When this method completes, it returns the results of the launch.
| Device family |
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v3)
|
- See Also
LaunchUriForUserAsync(User, Uri) LaunchUriForUserAsync(User, Uri) LaunchUriForUserAsync(User, Uri) LaunchUriForUserAsync(User, Uri)
Starts the default multi-user app associated with the URI scheme name for the specified URI and provides a specific User as context.
public : static IAsyncOperation<LaunchUriStatus> LaunchUriForUserAsync(User user, Uri uri)public static IAsyncOperation<LaunchUriStatus> LaunchUriForUserAsync(User user, Uri uri)Public Static Function LaunchUriForUserAsync(user As User, uri As Uri) As IAsyncOperation( Of LaunchUriStatus )// You can use this method in JavaScript.
- uri
- Uri Uri Uri Uri
The URI scheme.
The status of the launch attempt.
| Device family |
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v3)
|
LaunchUriForUserAsync(User, Uri, LauncherOptions) LaunchUriForUserAsync(User, Uri, LauncherOptions) LaunchUriForUserAsync(User, Uri, LauncherOptions) LaunchUriForUserAsync(User, Uri, LauncherOptions)
Starts the default multi-user app associated with the URI scheme name for the specified URI using the specified options, and provides a specific User as context.
public : static IAsyncOperation<LaunchUriStatus> LaunchUriForUserAsync(User user, Uri uri, LauncherOptions options)public static IAsyncOperation<LaunchUriStatus> LaunchUriForUserAsync(User user, Uri uri, LauncherOptions options)Public Static Function LaunchUriForUserAsync(user As User, uri As Uri, options As LauncherOptions) As IAsyncOperation( Of LaunchUriStatus )// You can use this method in JavaScript.
- uri
- Uri Uri Uri Uri
The URI scheme.
The launch options for the app.
The status of the launch attempt.
| Device family |
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v3)
|
LaunchUriForUserAsync(User, Uri, LauncherOptions, ValueSet) LaunchUriForUserAsync(User, Uri, LauncherOptions, ValueSet) LaunchUriForUserAsync(User, Uri, LauncherOptions, ValueSet) LaunchUriForUserAsync(User, Uri, LauncherOptions, ValueSet)
Starts the default multi-user app associated with the URI scheme name for the specified URI, using the specified options and input data, and provides a specific User as context.
public : static IAsyncOperation<LaunchUriStatus> LaunchUriForUserAsync(User user, Uri uri, LauncherOptions options, ValueSet inputData)public static IAsyncOperation<LaunchUriStatus> LaunchUriForUserAsync(User user, Uri uri, LauncherOptions options, ValueSet inputData)Public Static Function LaunchUriForUserAsync(user As User, uri As Uri, options As LauncherOptions, inputData As ValueSet) As IAsyncOperation( Of LaunchUriStatus )// You can use this method in JavaScript.
- uri
- Uri Uri Uri Uri
The URI scheme.
The launch options for the app.
The status of the launch attempt.
| Device family |
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v3)
|
QueryAppUriSupportAsync(Uri) QueryAppUriSupportAsync(Uri) QueryAppUriSupportAsync(Uri) QueryAppUriSupportAsync(Uri)
Asynchronously query whether there is an app that can handle the specified URI.
public : static IAsyncOperation<LaunchQuerySupportStatus> QueryAppUriSupportAsync(Uri uri)public static IAsyncOperation<LaunchQuerySupportStatus> QueryAppUriSupportAsync(Uri uri)Public Static Function QueryAppUriSupportAsync(uri As Uri) As IAsyncOperation( Of LaunchQuerySupportStatus )// You can use this method in JavaScript.
- uri
- Uri Uri Uri Uri
The URI of the website.
A value that indicates whether an application is available to handle the URI.
| Device family |
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v3)
|
Remarks
Windows desktop application are not considered.
- See Also
QueryAppUriSupportAsync(Uri, String) QueryAppUriSupportAsync(Uri, String) QueryAppUriSupportAsync(Uri, String) QueryAppUriSupportAsync(Uri, String)
Asynchronously query whether the specified app can handle the specified URI.
public : static IAsyncOperation<LaunchQuerySupportStatus> QueryAppUriSupportAsync(Uri uri, PlatForm::String packageFamilyName)public static IAsyncOperation<LaunchQuerySupportStatus> QueryAppUriSupportAsync(Uri uri, String packageFamilyName)Public Static Function QueryAppUriSupportAsync(uri As Uri, packageFamilyName As String) As IAsyncOperation( Of LaunchQuerySupportStatus )// You can use this method in JavaScript.
- uri
- Uri Uri Uri Uri
The URI of the website.
- packageFamilyName
- PlatForm::String String String String
Specifies a specific package that will be used to launch this URI.
A value that indicates whether the application is available to launch the URI.
| Device family |
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v3)
|
Remarks
Windows desktop application are not considered.
- See Also
QueryFileSupportAsync(StorageFile) QueryFileSupportAsync(StorageFile) QueryFileSupportAsync(StorageFile) QueryFileSupportAsync(StorageFile)
Asynchronously query whether an app can be activated for the specified file.
public : static IAsyncOperation<LaunchQuerySupportStatus> QueryFileSupportAsync(StorageFile file)public static IAsyncOperation<LaunchQuerySupportStatus> QueryFileSupportAsync(StorageFile file)Public Static Function QueryFileSupportAsync(file As StorageFile) As IAsyncOperation( Of LaunchQuerySupportStatus )// You can use this method in JavaScript.
The file for which to query support.
A value that indicates whether an application can be activated for the file.
Remarks
This API may also be called from Windows desktop application.
Both Windows desktop application and Universal Windows Platform (UWP) app are considered.
- See Also
QueryFileSupportAsync(StorageFile, String) QueryFileSupportAsync(StorageFile, String) QueryFileSupportAsync(StorageFile, String) QueryFileSupportAsync(StorageFile, String)
Asynchronously query whether an app with the specified package name can be activated for the specified file.
public : static IAsyncOperation<LaunchQuerySupportStatus> QueryFileSupportAsync(StorageFile file, PlatForm::String packageFamilyName)public static IAsyncOperation<LaunchQuerySupportStatus> QueryFileSupportAsync(StorageFile file, String packageFamilyName)Public Static Function QueryFileSupportAsync(file As StorageFile, packageFamilyName As String) As IAsyncOperation( Of LaunchQuerySupportStatus )// You can use this method in JavaScript.
The file for which to query support.
- packageFamilyName
- PlatForm::String String String String
The package for which to query support.
A value that indicates whether an application can be activated for the file.
Remarks
This API may also be called from Windows desktop application.
Both Windows desktop application and Universal Windows Platform (UWP) app are considered.
- See Also
QueryUriSupportAsync(Uri, LaunchQuerySupportType) QueryUriSupportAsync(Uri, LaunchQuerySupportType) QueryUriSupportAsync(Uri, LaunchQuerySupportType) QueryUriSupportAsync(Uri, LaunchQuerySupportType)
Asynchronously query whether an app can be activated for the specified URI and launch type.
public : static IAsyncOperation<LaunchQuerySupportStatus> QueryUriSupportAsync(Uri uri, LaunchQuerySupportType launchQuerySupportType)public static IAsyncOperation<LaunchQuerySupportStatus> QueryUriSupportAsync(Uri uri, LaunchQuerySupportType launchQuerySupportType)Public Static Function QueryUriSupportAsync(uri As Uri, launchQuerySupportType As LaunchQuerySupportType) As IAsyncOperation( Of LaunchQuerySupportStatus )// You can use this method in JavaScript.
- uri
- Uri Uri Uri Uri
The URI for which to query support.
- launchQuerySupportType
- LaunchQuerySupportType LaunchQuerySupportType LaunchQuerySupportType LaunchQuerySupportType
The type of launch for which to query support.
A value that indicates whether an application is available to launch the URI.
Remarks
This API may also be called from Windows desktop application.
Both Windows desktop application and Universal Windows Platform (UWP) app are considered.
- See Also
QueryUriSupportAsync(Uri, LaunchQuerySupportType, String) QueryUriSupportAsync(Uri, LaunchQuerySupportType, String) QueryUriSupportAsync(Uri, LaunchQuerySupportType, String) QueryUriSupportAsync(Uri, LaunchQuerySupportType, String)
Asynchronously query whether an app can be activated for the specified URI, launch type, and package name.
public : static IAsyncOperation<LaunchQuerySupportStatus> QueryUriSupportAsync(Uri uri, LaunchQuerySupportType launchQuerySupportType, PlatForm::String packageFamilyName)public static IAsyncOperation<LaunchQuerySupportStatus> QueryUriSupportAsync(Uri uri, LaunchQuerySupportType launchQuerySupportType, String packageFamilyName)Public Static Function QueryUriSupportAsync(uri As Uri, launchQuerySupportType As LaunchQuerySupportType, packageFamilyName As String) As IAsyncOperation( Of LaunchQuerySupportStatus )// You can use this method in JavaScript.
- uri
- Uri Uri Uri Uri
The URI for which to query support.
- launchQuerySupportType
- LaunchQuerySupportType LaunchQuerySupportType LaunchQuerySupportType LaunchQuerySupportType
The type of launch for which to query support.
- packageFamilyName
- PlatForm::String String String String
Specifies a specific package that will be used to launch this URI.
A value that indicates whether the application is available to launch the URI.
Remarks
This API may also be called from Windows desktop application.
Both Windows desktop application and Universal Windows Platform (UWP) app are considered.
- See Also
See Also
- How to launch the default app for a file (JavaScript)
- Launch the default app for a file
- How to launch the default app for a URI (JavaScript)
- Launch the default app for a URI
- Association launching sample
- Guidelines for file types and URIs
- LauncherOptions LauncherOptions LauncherOptions LauncherOptions