CommandLineActivatedEventArgs
CommandLineActivatedEventArgs
CommandLineActivatedEventArgs
CommandLineActivatedEventArgs
Class
Definition
Some information relates to pre-released product which may be substantially modified before it’s commercially released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Prerelease APIs are identified by a Prerelease label.
[Contains prerelease APIs.]
Provides information, such as the command-line arguments, when an app is activated from the command line.
public : sealed class CommandLineActivatedEventArgs : IActivatedEventArgs, IActivatedEventArgsWithUser, ICommandLineActivatedEventArgspublic sealed class CommandLineActivatedEventArgs : IActivatedEventArgs, IActivatedEventArgsWithUser, ICommandLineActivatedEventArgsPublic NotInheritable Class CommandLineActivatedEventArgs Implements IActivatedEventArgs, IActivatedEventArgsWithUser, ICommandLineActivatedEventArgs// You can use this class in JavaScript.
- Attributes
| Device family |
Windows 10 Insider Preview (introduced v10.0.16257.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v5)
|
Examples
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;
break;
// 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;
break;
}
// Parse the trusted activation arguments.
ParseTrustedArgs(activationArgString);
// 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.
}
Remarks
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" />
</uap5:AppExecutionAlias>
</uap5:Extension>
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.
Properties
Kind Kind Kind Kind
Prerelease. Gets the type of activation that launched the app.
public : ActivationKind Kind { get; }public ActivationKind Kind { get; }Public ReadOnly Property Kind As ActivationKind// You can use this property in JavaScript.
The activation kind.
Remarks
The expected value is ActivationKind.CommandLineLaunch.
Operation Operation Operation Operation
Prerelease. Gets info about the activation of the app such as what arguments were provided and the current directory path.
public : CommandLineActivationOperation Operation { get; }public CommandLineActivationOperation Operation { get; }Public ReadOnly Property Operation As CommandLineActivationOperation// You can use this property in JavaScript.
- Value
- CommandLineActivationOperation CommandLineActivationOperation CommandLineActivationOperation CommandLineActivationOperation
The activation info.
Remarks
The app supplies the exit code which is passed back to the caller.
- See Also
PreviousExecutionState PreviousExecutionState PreviousExecutionState PreviousExecutionState
Prerelease. Gets the execution state of the app before it was activated.
public : ApplicationExecutionState PreviousExecutionState { get; }public ApplicationExecutionState PreviousExecutionState { get; }Public ReadOnly Property PreviousExecutionState As ApplicationExecutionState// You can use this property in JavaScript.
- Value
- ApplicationExecutionState ApplicationExecutionState ApplicationExecutionState ApplicationExecutionState
The execution state before the app was activated.
SplashScreen SplashScreen SplashScreen SplashScreen
Prerelease. Gets info about the transition from the splash screen to the activated app.
public : SplashScreen SplashScreen { get; }public SplashScreen SplashScreen { get; }Public ReadOnly Property SplashScreen As SplashScreen// You can use this property in JavaScript.
The splash screen transition info.