Skip to content

Commit

Permalink
Added VS solution and updated readme for new project.
Browse files Browse the repository at this point in the history
  • Loading branch information
David Hall committed Sep 6, 2017
1 parent 5c4f979 commit f3b1689
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 97 deletions.
31 changes: 31 additions & 0 deletions ITaskHandlerTemplate.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26730.12
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "COMTask", "COMTask\COMTask.csproj", "{D8FF73D8-57A2-42E4-98C3-76C129BBB8F0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ITaskHandler COM Server Project Template", "ITaskHandler COM Server Project Template\ITaskHandler COM Server Project Template.csproj", "{601FB415-6066-47F7-9549-938AC0C40396}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D8FF73D8-57A2-42E4-98C3-76C129BBB8F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D8FF73D8-57A2-42E4-98C3-76C129BBB8F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D8FF73D8-57A2-42E4-98C3-76C129BBB8F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D8FF73D8-57A2-42E4-98C3-76C129BBB8F0}.Release|Any CPU.Build.0 = Release|Any CPU
{601FB415-6066-47F7-9549-938AC0C40396}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{601FB415-6066-47F7-9549-938AC0C40396}.Debug|Any CPU.Build.0 = Debug|Any CPU
{601FB415-6066-47F7-9549-938AC0C40396}.Release|Any CPU.ActiveCfg = Release|Any CPU
{601FB415-6066-47F7-9549-938AC0C40396}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {CF33C8D9-5FEE-49DE-8FC1-2FAB87B37F89}
EndGlobalSection
EndGlobal
99 changes: 2 additions & 97 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,98 +1,3 @@
# Task Scheduler Managed Wrapper
# ITaskHandler Template and Sample Project

> Provides a .NET wrapper for the Windows Task Scheduler. It aggregates the multiple versions, provides an editor and allows for localization.
API documentation can be found at https://dahall.github.io/TaskScheduler.

## Installation
This project's assemblies are available via NuGet.

* Main Library: [Task Scheduler Managed Wrapper](http://www.nuget.org/packages/TaskScheduler/) (TaskScheduler)
* UI Library: [Task Scheduler Managed Wrapper UI Library](http://www.nuget.org/packages/TaskSchedulerEditor/) (TaskSchedulerEditor)

## Project Components
### Main Library
Microsoft introduced version 2.0 (internally version 1.2) with a completely new object model with Windows Vista. The managed assembly closely resembles the new object model, but allows the 1.0 (internally version 1.1) COM objects to be manipulated. It will automatically choose the most recent version of the library found on the host system (up through 1.4). Core features include:

* Separate, functionally identical, libraries for .NET 2.0 and 4.0\.
* Unlike the base library, this wrapper helps to create and view tasks up and down stream.
* Written in C#, but works with any .NET language including scripting languages (e.g. PowerShell).
* Supports almost all V2 native properties, even under V1 systems.
* Maintain EmailAction and ShowMessageAction using PowerShell scripts for systems after Win8 where these actions have been deprecated
* Supports all action types (not just ExecAction) on V1 systems (XP/WS2003) and earlier (if PowerShell is installed).
* Supports multiple actions on V1 systems (XP/WS2003). Native library only supports a single action.
* Supports serialization to XML for both 1.0 and 2.0 tasks (base library only supports 2.0)
* Supports task validation for targeted version.
* Supports secure task reading and maintenance.
* Fluent methods for task creation.
* Cron syntax for trigger creation.
* Supports reading "custom" triggers under Win8 and later.
* Numerous work-arounds and checks to compensate for base library shortcomings.

The project supports a number of languages and, upon request, is ready to support others. The currently supported languages include: English, Spanish, Italian, French, Chinese (Simplified), German.

The project is based on work the originator started in January 2002 with the 1.0 library that is currently hosted on [CodeProject](http://www.codeproject.com/KB/system/taskschedulerlibrary.aspx).

### UI Library
There is a second library that includes localized and localizable GUI editors and a wizard for tasks which mimic the ones in Vista and later and adds optional pages for new properties. Following is the list of available UI controls:

* A DropDownCheckList control that is very useful for selecting flag type enumerations.
* A FullDateTimePicker control which allows both date and time selection in a single control.
* A CredentialsDialog class for prompting for a password which wraps the Windows API.
* Simplified classes for pulling events from the system event log.
* Action editor dialog
* Trigger editor dialog
* Task editor dialog and tabbed control
* Event viewer dialog
* Task / task folder selection dialog
* Task history viewer
* Task run-times viewer
* Task creation wizard
* Task service connection dialog

### COM Handler Project Template
If you are writing your own custom Task Scheduler COM Handler based on the <span class="codeInline">ITaskHandler</span> interface, there is a [project template](http://taskscheduler.codeplex.com/releases/view/142773) available that will stub out the majority of the work to create it in C# and a [sample](http://taskscheduler.codeplex.com/releases/view/29938) to show a complete one. If running your own code, this model provides much better interaction, control and memory management than running an executable.

## Sample Code
There is a help file included with the download that provides an overview of the various classes. There are numerous examples under the "Documentation" tab.

You can perform a number of actions in a single line of code:
```C#
// Run a program every day on the local machine
TaskService.Instance.AddTask("Test", QuickTriggerType.Daily, "myprogram.exe", "-a arg");

// Run a custom COM handler on the last day of every month
TaskService.Instance.AddTask("Test", new MonthlyTrigger { RunOnLastDayOfMonth = true },
new ComHandlerAction(new Guid("{CE7D4428-8A77-4c5d-8A13-5CAB5D1EC734}")));
```

For many more options, use the library classes to build a complex task. Below is a brief example of how to use the library from C#.
```C#
using System;
using Microsoft.Win32.TaskScheduler;

class Program
{
static void Main(string[] args)
{
// Get the service on the remote machine
using (TaskService ts = new TaskService(@"\\RemoteServer"))
{
// Create a new task definition and assign properties
TaskDefinition td = ts.NewTask();
td.RegistrationInfo.Description = "Does something";

// Create a trigger that will fire the task at this time every other day
td.Triggers.Add(new DailyTrigger { DaysInterval = 2 });

// Create an action that will launch Notepad whenever the trigger fires
td.Actions.Add(new ExecAction("notepad.exe", "c:\\test.log", null));

// Register the task in the root folder
ts.RootFolder.RegisterTaskDefinition(@"Test", td);
}
}
}
```

For extended examples on how to the use the library, look in the source code area or look at the [Examples Page](https://github.com/dahall/TaskScheduler/wiki/Examples). The library closely follows the Task Scheduler 2.0 Scripting classes. Microsoft has some examples on [MSDN](http://msdn2.microsoft.com/en-us/library/aa384006(VS.85).aspx) around it that may further help you understand how to use this library.
> Provides a sample project to demonstrate using C# to create a Task Scheduler COM Handler and a Visual Studio template project to easily create a custom handler.

0 comments on commit f3b1689

Please sign in to comment.