Converting TaskDefinition to work with Server 2003 R2

Topics: Setup
Nov 30, 2012 at 10:42 PM

Is it possible to take a TaskDefinition made with the Task Scheduler Wizard on a Windows 7/2008 R2 machine and make it so it is also compatible with Server 2003?

Nov 30, 2012 at 11:51 PM

Yes. Disallow the addition of any trigger and action types not supported under V1 and then don't tell it to RegisterTaskOnFinish. Once the wizard is complete, you will have a TaskDefinition. Set its Settings.Compatibility to V1. You can then register this TaskDefinition by connecting a TaskService instance to the WS2003 machine and calling the TaskService.RootFolder.RegisterTaskDefinition method.

Dec 4, 2012 at 5:39 PM

When I do this I get a null error on

V1Interop.TaskFlags flags = definition.v1Task.GetFlags();


Dec 5, 2012 at 2:44 AM

Try creating the TaskService with the forceV1 parameter set to true and pass this into the TaskSchedulerWizard.Initialize() method. Then don't change the Settings.Compatibility property.

Dec 10, 2012 at 7:50 PM

Here is how I am trying to convert it, still gives me a Null error:


 TaskService ts = new TaskService(txtServerName.Text, logon[1], logon[0], logon[2], true);

EditorForm.TaskDefinition.Settings.Compatibility = TaskCompatibility.V1;

TaskSchedulerWizard tempEditorForm = new TaskSchedulerWizard(ts, EditorForm.TaskDefinition, false);

Dec 11, 2012 at 1:51 AM

You only need the following:

TaskService ts = new TaskService(txtServerName.Text, logon[1], logon[0], logon[2], true);
TaskSchedulerWizard tempEditorForm = new TaskSchedulerWizard(ts);
if (tempEditorForm.ShowDialog() == DialogResult.OK)
   // You can use tempEditorForm.TaskDefinition here to modify however you want
// You must register it to make it take effect
// You do not need to change the Compatibility property
Mar 13, 2015 at 1:56 PM
How to dynamically decide what to use for a remote computer ? forceV1=true or false?
Mar 13, 2015 at 5:03 PM
If a server's version is Windows Server 2003 R2 or earlier or XP or earlier (major version <= 5) then you should force V1 (= true).
Marked as answer by dahall on 3/13/2015 at 10:03 AM