

You should treat these arguments as untrustworthy and parse them very carefully. It’s important to remember that the command-line arguments are supplied by the caller, which means that you have no control over them. String activationPath = operation.CurrentDirectoryPath

String cmdLineString = operation.Arguments This is typically not the install location of the app itself, but could be any arbitrary path.Īsync protected override void OnActivated(IActivatedEventArgs args)ĬommandLineActivatedEventArgs cmdLineArgs =ĬommandLineActivationOperation operation = cmdLineArgs.Operation You also get the CurrentDirectoryPath, which is the directory current when the command-line activation request was made.

From this, you can get the CommandLineActivationOperation, and from this in turn, you can get the Arguments string. In this scenario, if the ActivationKind is CommandLineLaunch, the incoming IActivatedEventArgs will be an object of type CommandLineActivatedEventArgs. Instead of Executable, you specify a StartPage, and you don’t specify EntryPoint at all:įor the OnActivated override, the first thing to do is to check the ActivationKind – this is standard practice if your app supports multiple activation kinds (file associations, custom protocols and so on). The manifest entry is obviously the same for VB and C++ projects, but for a JavaScript web app, it’s slightly different. The rule here is that the first one wins. Similarly, if your app is installed first, and then the user installs another app later that declares the same alias – then your app will take precedence. Note that if you choose an alias that conflicts with an app that is already installed, your alias won’t be used. The ExecutionAlias is the name that users will type in at the command-line: This can be any arbitrary name, and it must end with “.exe.” You should choose a meaningful alias that you can reasonably expect the user to associate with your app. The Executable is the name of your UWA app EXE, and the EntryPoint is the fully qualified name of your App class. This is quite simple and almost the same as for a Desktop Bridge app: The AppExecutionAlias is declared as an Extension within your Application. Override OnActivated and handle the incoming arguments.įor the manifest entry, you first need to declare the XML namespace for the AppExecutionAlias element:.Add an appExecutionAlias extension to your app manifest.To use this feature in a UWA, there are two key additions to your app: This feature builds on the App Execution Alias extension already available for Desktop Bridge apps. This is available to Insiders from build 16226. As we continue to close the gap between Win32 and Universal Windows Apps, one of the features we’ve recently introduced is the ability to activate a UWA from a command line and pass the app arbitrary command-line arguments.
