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

Task being deleted when Run Times tab is selected (XP)

Feb 2, 2012 at 1:41 PM

I'm creating tasks with the following code:

using (TaskService ts = new TaskService())
                {
                    for (int i = 0; i <= sTasks.GetUpperBound(0); i++)
                    {
                        string taskName = sTasks[i, 0];
                        if (ts.FindTask(sTasks[i, 0]) == null)
                        {
                            #region Create Scheduled Task
                            // Create a new task definition and assign properties
                            TaskDefinition td = ts.NewTask();
                            td.Principal.LogonType = TaskLogonType.InteractiveToken;

                            // Add an action to execute the Batch File
                            td.Actions.Add(new ExecAction(sTasks[i, 1], null, "C:\\Configuration\\Infrastructure\\Test Runs\\Standard"));

                            // Create a Trigger
                            TimeTrigger tTrigger = (TimeTrigger)td.Triggers.Add(new TimeTrigger());
                            tTrigger.StartBoundary = DateTime.Today + TimeSpan.Parse("00:00:00");

                            // Un-Hidden
                            td.Settings.Hidden = false;

                            // Register the task in the root folder
                            ts.RootFolder.RegisterTaskDefinition(taskName, td);
                            #endregion
                        }

                    }
                }

On an XP machine, when I use the following code and click on the Run Times tab, the task is being deleted:

TaskEditDialog editorForm = new TaskEditDialog(task, true, true);
editorForm.ShowDialog();

This also causes on occasion for the Action Program/Script field to overwrite with C:\WINDOWS\system32\rundll32.exe.

Feb 2, 2012 at 1:55 PM

Follow these steps to overwrite the Action Details and 'Hide' the task in XP:

  1. Run the above code to create the task.
  2. ShowDialog();
    1. Change Trigger to Daily and click OK to register the task.
  3. ShowDialog(); again
    1. Click Run Times tab and click OK

NOTE: The task in XP has been Hidden and the Action Program/Script has been overwritten with C:\WINDOWS\system32\rundll32.exe

Coordinator
Feb 2, 2012 at 6:08 PM

You found a bug. I believe I have corrected it in build 74563. Thank you.

Feb 2, 2012 at 8:10 PM

Thanks for the quick update.  I've compiled and deployed.  Works great.