Click or drag to resize
Task Scheduler Managed Class Library

TaskService Class

Provides access to the Task Scheduler service for managing registered tasks.
Inheritance Hierarchy
SystemObject
  SystemMarshalByRefObject
    System.ComponentModelComponent
      Microsoft.Win32.TaskSchedulerTaskService

Namespace: Microsoft.Win32.TaskScheduler
Assembly: Microsoft.Win32.TaskScheduler (in Microsoft.Win32.TaskScheduler.dll) Version: 2.12.0
Syntax
C#
[SerializableAttribute]
public sealed class TaskService : Component, 
	ISupportInitialize, ISerializable
Request Example View Source

The TaskService type exposes the following members.

Constructors
 NameDescription
Public methodTaskServiceCreates a new instance of a TaskService connecting to the local machine as the current user.
Public methodTaskService(String, String, String, SecureString, Boolean)Initializes a new instance of the TaskService class.
Public methodTaskService(String, String, String, String, Boolean)Initializes a new instance of the TaskService class.
Top
Properties
 NameDescription
Public propertyAllowReadOnlyTasks Gets or sets a value indicating whether to allow tasks from later OS versions with new properties to be retrieved as read only tasks.
Public propertyAllTasksGets a IEnumeratorT which enumerates all the tasks in all folders.
Protected propertyCanRaiseEventsGets a value indicating whether the component can raise an event.
(Overrides ComponentCanRaiseEvents)
Public propertyConnectedGets a Boolean value that indicates if you are connected to the Task Scheduler service.
Public propertyConnectedDomainObsolete.
Gets the name of the domain to which the TargetServer computer is connected.
Public propertyConnectedUserObsolete.
Gets the name of the user that is connected to the Task Scheduler service.
Public propertyContainerGets the IContainer that contains the Component.
(Inherited from Component)
Protected propertyDesignModeGets a value that indicates whether the Component is currently in design mode.
(Inherited from Component)
Protected propertyEventsGets the list of event handlers that are attached to this Component.
(Inherited from Component)
Public propertyHighestSupportedVersionGets the highest version of Task Scheduler that a computer supports.
Public propertyStatic memberInstanceGets a local instance of the TaskService using the current user's credentials.
Public propertyStatic memberLibraryVersion Gets the library version. This is the highest version supported by the local library. Tasks cannot be created using any compatibility level higher than this version.
Public propertyRootFolderGets the root ("\") folder. For Task Scheduler 1.0, this is the only folder.
Public propertySiteGets or sets the ISite of the Component.
(Inherited from Component)
Public propertyTargetServerGets or sets the name of the computer that is running the Task Scheduler service that the user is connected to.
Public propertyToken Gets the connection token for this TaskService instance. This token is thread safe and can be used to create new TaskService instances on other threads using the CreateFromToken(TaskServiceConnectionToken) static method.
Public propertyUserAccountDomainGets or sets the user account domain to be used when connecting to the TargetServer.
Public propertyUserNameGets or sets the user name to be used when connecting to the TargetServer.
Public propertyUserPasswordGets or sets the user password to be used when connecting to the TargetServer.
Top
Methods
 NameDescription
Public methodAddAutomaticMaintenanceTaskAdds or updates an Automatic Maintenance Task on the connected machine.
Public methodCode exampleAddTask(String, Trigger, Action, String, String, TaskLogonType, String)Creates a new task, registers the task, and returns the instance.
Public methodCode exampleAddTask(String, QuickTriggerType, String, String, String, String, TaskLogonType, String)Creates a new task, registers the task, and returns the instance.
Public methodBeginInitSignals the object that initialization is starting.
Public methodStatic memberCreateFromToken Creates a new TaskService instance from a token. Given that a TaskService instance is thread specific, this is the preferred method for multi-thread creation or asynchronous method parameters.
Public methodCreateObjRefCreates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
(Inherited from MarshalByRefObject)
Public methodDisposeReleases all resources used by the Component.
(Inherited from Component)
Protected methodDispose(Boolean) Releases the unmanaged resources used by the Component and optionally releases the managed resources.
(Overrides ComponentDispose(Boolean))
Public methodEndInitSignals the object that initialization is complete.
Public methodEqualsDetermines whether the specified Object, is equal to this instance.
(Overrides ObjectEquals(Object))
Public methodExecuteInitial call for a Fluent model of creating a task.
Protected methodFinalizeReleases unmanaged resources and performs other cleanup operations before the Component is reclaimed by garbage collection.
(Inherited from Component)
Public methodCode exampleFindAllTasks(PredicateTask, Boolean)Finds all tasks matching a name or standard wildcards.
Public methodFindAllTasks(Regex, Boolean)Finds all tasks matching a name or standard wildcards.
Public methodFindTaskFinds a task given a name and standard wildcards.
Public methodStatic memberCode exampleGetDllResourceStringGets a formatted string that tells the Task Scheduler to retrieve a string from a resource .dll file.
Public methodGetEventLogGets the event log for this TaskService instance.
Public methodGetFolderGets the path to a folder of registered tasks.
Public methodGetHashCodeReturns a hash code for this instance.
(Overrides ObjectGetHashCode)
Public methodGetLifetimeServiceRetrieves the current lifetime service object that controls the lifetime policy for this instance.
(Inherited from MarshalByRefObject)
Public methodGetRunningTasksGets a collection of running tasks.
Protected methodGetServiceReturns an object that represents a service provided by the Component or by its Container.
(Inherited from Component)
Public methodGetTaskGets the task with the specified path.
Public methodGetTypeGets the Type of the current instance.
(Inherited from Object)
Public methodInitializeLifetimeServiceObtains a lifetime service object to control the lifetime policy for this instance.
(Inherited from MarshalByRefObject)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
Protected methodMemberwiseClone(Boolean)Creates a shallow copy of the current MarshalByRefObject object.
(Inherited from MarshalByRefObject)
Public methodNewTask Returns an empty task definition object to be filled in with settings and properties and then registered using the RegisterTaskDefinition(String, TaskDefinition) method.
Public methodNewTaskFromFileReturns a TaskDefinition populated with the properties defined in an XML file.
Public methodStatic memberRunComHandlerAction Runs an action that is defined via a COM handler. COM CLSID must be registered to an object that implements the ITaskHandler interface.
Public methodStatic memberRunComHandlerActionAsync Runs an action that is defined via a COM handler. COM CLSID must be registered to an object that implements the ITaskHandler interface.
Public methodSetUserSecurePasswordSets the user password as a secure string to be used when connecting to the TargetServer.
Public methodStartSystemTaskSchedulerManagerStarts the Task Scheduler UI for the OS hosting the assembly if the session is running in interactive mode.
Public methodToStringReturns a String containing the name of the Component, if any. This method should not be overridden.
(Inherited from Component)
Top
Events
 NameDescription
Public eventDisposedOccurs when the component is disposed by a call to the Dispose method.
(Inherited from Component)
Public eventServiceConnectedOccurs when the Task Scheduler is connected to the local or remote target.
Public eventServiceDisconnectedOccurs when the Task Scheduler is disconnected from the local or remote target.
Top
Extension Methods
 NameDescription
Public Extension MethodGetFilteredAvailableActionsFiltered the supplied available actions based on this version of the Task Scheduler and options that could be set on the TaskDefinition.
(Defined by TaskServiceExtensions)
Public Extension MethodGetFilteredAvailableTriggersFiltered the supplied available triggers based on this version of the Task Scheduler and options that could be set on the TaskDefinition.
(Defined by TaskServiceExtensions)
Top
See Also