dahall / TaskScheduler

Provides a .NET wrapper for the Windows Task Scheduler. It aggregates the multiple versions, provides an editor and allows for localization.
MIT License
1.21k stars 191 forks source link

TaskService ImportTask #817

Closed GromitD90 closed 5 years ago

GromitD90 commented 5 years ago

I am making the following call to Import a scheduled task from an xml file. TaskService.Instance.RootFolder.ImportTask(taskname, item);

This works even if a scheduled task by the name taskname already exists. The old task is just deleted and overwritten with the new one.

Is this expected behaviour? Is there any way to determine if such an event has occurred?

Importing a task manually to the task scheduler does alert you to the fact that a task already exists.

Apologies if this should not have used the bug reporting process

Expected behavior I would expect that the ImportTask method would return an error code

Screenshots If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

Additional context Add any other context about the problem here.

dahall commented 5 years ago

This is a good callout. Thanks! Unintended consequences is a bad model. As such, I have added a boolean parameter to the end of the ImportTask called overwriteExisting and set its default so that it behaves the same as the current implementation. However, for your purposes, it should allow you to capture the condition where the task already exists and will throw an exception. Code is committed and will be included in 2.8.14 after testing completes.

GromitD90 commented 5 years ago

Thank you for such a fast response. This is what I call awesome support.

Sent from my iPhone

On Jul 17, 2019, at 11:31 AM, David Hall notifications@github.com wrote:

Closed #817.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

dahall commented 5 years ago

You're welcome. I think under 30 minutes is a record for me. The stars aligned with me getting your email when it arrived, being in front of my dev station, and finding an easy fix.