This project has moved. For the latest updates, please go here.

Problems w/V1 disabling task after RegisterTaskDefinition

Feb 19, 2012 at 8:20 PM

First, I want to say what a great help this project is.  It has saved me a lot of hassles.

Maybe I just don't know the right way to do this, but my intention is to register a disabled task to be enabled at a later time.  My code calls RootFolder.RegisterTaskDefinition and immediately sets Enabled on the returned Task object to false.  This works fine on my Windows 7 development machine, but on my Server 2003 test system the task remains enabled.  I assume it has something to do with the difference between Task Scheduler versions, but I don't know what.

Is this the best way to register a disabled task?  Is there a bug in the wrapper?

... Jim Hansen
Canyon Country Consulting

Coordinator
Feb 20, 2012 at 3:50 AM
Edited Feb 20, 2012 at 4:03 AM

This may be classified as a bug given that it performs different on V1 vs. V2. For your problem on Server 2003, until I get a fix in place, call Task.RegisterChanges() after setting the Enabled property.

You also, for consistency sake, may consider using the Task.Definition.Settings.Enabled property instead as this is a property that will take effect when you register the task instead of trying to do it after registering.

Feb 20, 2012 at 1:03 PM

Perfect! That solves my problem.

I had overlooked the Enabled property in Settings and that is really what I need anyway.  So, bug though it may be, I am set.

Thanks for the prompt reply and the fine work.

...Jim