CommandLineActivatedEventArgs Class


Provides information, such as the command-line arguments, when an app is activated from the command line.

public ref class CommandLineActivatedEventArgs sealed : IActivatedEventArgsWithUser, ICommandLineActivatedEventArgs
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 327680)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class CommandLineActivatedEventArgs final : IActivatedEventArgsWithUser, ICommandLineActivatedEventArgs
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 327680)]
public sealed class CommandLineActivatedEventArgs : IActivatedEventArgsWithUser, ICommandLineActivatedEventArgs
Public NotInheritable Class CommandLineActivatedEventArgs
Implements IActivatedEventArgsWithUser, ICommandLineActivatedEventArgs
Object IInspectable CommandLineActivatedEventArgs

Windows requirements

Device family
Windows 10 Fall Creators Update (introduced in 10.0.16299.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v5.0)


Here is an example of handling a command-line launch:

protected override void OnActivated(IActivatedEventArgs args)
    string activationArgString = string.Empty;
    string activationPath = string.Empty;
    string cmdLineString = string.Empty;

    // Existing behavior to differentiate different activation kinds,
    // and to extract any argument payload.
    switch (args.Kind)
        case ActivationKind.Launch:
            var launchArgs = args as LaunchActivatedEventArgs;
            activationArgString = launchArgs.Arguments;

        // A new ActivationKind for console activation of a windowed app.
        case ActivationKind.CommandLineLaunch:
            CommandLineActivatedEventArgs cmdLineArgs = args as CommandLineActivatedEventArgs;
            CommandLineActivationOperation operation = cmdLineArgs.Operation;
            cmdLineString = operation.Arguments;
            activationPath = operation.CurrentDirectoryPath;

    // Parse the trusted activation arguments.

    // Parse the untrusted command-line arguments.
    ParseUntrustedArgs(activationPath, cmdLineString);

    // Since we did not take a deferral, the calling app gets the result
    // as soon as this method returns. Since we did not set an exit code,
    // the calling app gets a default exit code as the result.


A UWP app may be activated from Start|Run in Windows, from the command line in PowerShell, the DOS command prompt, or from another Win32 process that calls CreateProcess().

To be activated from the command line, your app must register for the "AppExecutionAlias" extension category in its manifest.

<uap5:Extension Category="windows.appExecutionAlias" Executable="FruitSalad.exe" EntryPoint="Windows.FruitSalad.Bananas.App">
    <uap5:AppExecutionAlias >
        <uap5:ExecutionAlias Alias="Fs.exe" />

After you register in your manifest, your app can be activated from the command line. When your app is activated, you can use the event information to identify the call activation and extract the parameters that help you complete the call for the user.



Gets the type of activation that launched the app.


Gets info about the activation of the app such as what arguments were provided and the current directory path.


Gets the execution state of the app before it was activated.


Gets info about the transition from the splash screen to the activated app.


Gets the user that the app was activated for.

Applies to