Launcher.LaunchUriAsync(Uri, LauncherOptions) | launchUriAsync(Uri, LauncherOptions) method

Applies to Windows and Windows Phone

Starts the default app associated with the URI scheme name for the specified URI, using the specified options.

Syntax


Public Shared Function LaunchUriAsync(
  uri As Uri,  
  options As LauncherOptions 
) As IAsyncOperation(Of Boolean)

Parameters

uri

Type: Windows.Foundation.Uri [JavaScript] | System.Uri [.NET] | Windows::Foundation::Uri [C++]

The URI.

options

Type: LauncherOptions

The launch options for the app.

Return value

Type: IAsyncOperation<Boolean>

The launch operation.

Remarks

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.

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 Store apps 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
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

Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]

Namespace

Windows.System
Windows::System [C++]

Metadata

Windows.winmd

See also

Samples
Association launching sample
Guidelines
Guidelines and checklist for file types and URIs
Tasks
How to launch the default app for a URI (JavaScript)
How to launch the default app for a URI (C#/VB/C++)
Reference
Launcher
LauncherOptions

 

 

Show:
© 2014 Microsoft