StartupTask
StartupTask
StartupTask
StartupTask
Class
Definition
Represents a background task that runs automatically whenever the user logs in to their device.
public : sealed class StartupTask : IStartupTaskpublic sealed class StartupTask : IStartupTaskPublic NotInheritable Class StartupTask Implements IStartupTask// You can use this class in JavaScript.
- Attributes
| Device family |
Windows Desktop Extension SDK (introduced v10.0.14393.0)
|
| API contract |
Windows.ApplicationModel.StartupTaskContract (introduced v1)
|
Remarks
This functionality is only supported on Windows Desktop.
An app must register for the "windows.startup" extension category in its manifest to be activated at startup or when a user logs in. Although this does not automatically make the app activatable at startup. The user must first launch the app, and the app must request to be enabled for startup activation, which will trigger a user-consent prompt.
desktop:Extension
Category="windows.startupTask"
Executable="bin\MyStartupTask.exe"
EntryPoint="Windows.FullTrustApplication">
<desktop:StartupTask
TaskId="MyStartupTask"
Enabled="true"
DisplayName="Some Arbitrary Name" />
</desktop:Extension>
Extension Category must have the value "windows.startupTask" Extension Executable is the relative path to the .exe to start Extension EntryPoint must have the value "Windows.FullTrustApplication" StartupTask TaskId is a unique identifier for your task. Using this identifier, your app can call the APIs in the Windows.ApplicationModel.StartupTask class to programmatically enable or disable a startup task. StartupTask Enabled indicates whether the task first starts enabled or disabled. Enabled tasks will run the next time the user logs on (unless the user disables it). StartupTask DisplayName is the name of the task that appears in Task Manager.
Properties
State State State State
Gets the state (enabled, disabled, or disabled by user) of the startup task.
public : StartupTaskState State { get; }public StartupTaskState State { get; }Public ReadOnly Property State As StartupTaskState// You can use this property in JavaScript.
The state of the startup task.
Methods
Disable() Disable() Disable() Disable()
Disables the startup task.
public : void Disable()public void Disable()Public Function Disable() As void// You can use this method in JavaScript.
GetAsync(String) GetAsync(String) GetAsync(String) GetAsync(String)
Gets a startup task by Id.
public : static IAsyncOperation<StartupTask> GetAsync(PlatForm::String taskId)public static IAsyncOperation<StartupTask> GetAsync(String taskId)Public Static Function GetAsync(taskId As String) As IAsyncOperation( Of StartupTask )// You can use this method in JavaScript.
- taskId
- PlatForm::String String String String
The Id of the startup task to get.
When this method completes, it returns the startup task with the given Id.
GetForCurrentPackageAsync() GetForCurrentPackageAsync() GetForCurrentPackageAsync() GetForCurrentPackageAsync()
Gets all startup tasks for the current app package.
public : static IAsyncOperation<IVectorView<StartupTask>> GetForCurrentPackageAsync()public static IAsyncOperation<IReadOnlyList<StartupTask>> GetForCurrentPackageAsync()Public Static Function GetForCurrentPackageAsync() As IAsyncOperation( Of IReadOnlyListStartupTask )// You can use this method in JavaScript.
When this method completes, it returns all startup tasks for the current app package.
RequestEnableAsync() RequestEnableAsync() RequestEnableAsync() RequestEnableAsync()
Requests that the startup task be enabled. If the task was disabled by the user using Task Manager, this method will not override their choice and the user must re-enable the task manually.
public : IAsyncOperation<StartupTaskState> RequestEnableAsync()public IAsyncOperation<StartupTaskState> RequestEnableAsync()Public Function RequestEnableAsync() As IAsyncOperation( Of StartupTaskState )// You can use this method in JavaScript.
When this method completes, it returns the state of the startup task.