Quantcast
Channel: Task Scheduler Managed Wrapper
Viewing all 2206 articles
Browse latest View live

Commented Unassigned: Inheritance security rules violated while overriding member [12037]

$
0
0
I'm trying to write a NAnt extension that uses this library but I get this exception on my first method that loads the taskscheduler objects.

System.TypeLoadException: Inheritance security rules violated while overriding member: 'Microsoft.Win32.TaskScheduler.TaskService.System.Runtime.Serialization.ISerializab
le.GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)'. Security accessibility of the overriding method must mat
ch the security accessibility of the method being overriden.

I'm assuming this is related to NAnt dynamically loading the extension dll but I'm not sure how to get around it. Previously we were using the taskscheduler 1.0 library via NAnt without any issues.

```
public void test()
{
using (Microsoft.Win32.TaskScheduler.TaskService ts = new Microsoft.Win32.TaskScheduler.TaskService())
{
// Create a new task definition and assign properties
Microsoft.Win32.TaskScheduler.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 Microsoft.Win32.TaskScheduler.DailyTrigger { DaysInterval = 2 });

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

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

}
}
```
Comments: ** Comment from web user: dahall **

After "test:", instead of getting the "Hello..." text, I get

BUILD FAILED

C:\Users\dahall\Documents\Visual Studio 2013\Projects\NAnt.Example.Tasks\testscheduledtasktest.nant(6,6):
Invalid element <testtask>. Unknown task or datatype.

Also, when I went to get the NAnt bits, I got version 0.92 and not the 0.91 from your text.


Commented Unassigned: Inheritance security rules violated while overriding member [12037]

$
0
0
I'm trying to write a NAnt extension that uses this library but I get this exception on my first method that loads the taskscheduler objects.

System.TypeLoadException: Inheritance security rules violated while overriding member: 'Microsoft.Win32.TaskScheduler.TaskService.System.Runtime.Serialization.ISerializab
le.GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)'. Security accessibility of the overriding method must mat
ch the security accessibility of the method being overriden.

I'm assuming this is related to NAnt dynamically loading the extension dll but I'm not sure how to get around it. Previously we were using the taskscheduler 1.0 library via NAnt without any issues.

```
public void test()
{
using (Microsoft.Win32.TaskScheduler.TaskService ts = new Microsoft.Win32.TaskScheduler.TaskService())
{
// Create a new task definition and assign properties
Microsoft.Win32.TaskScheduler.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 Microsoft.Win32.TaskScheduler.DailyTrigger { DaysInterval = 2 });

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

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

}
}
```
Comments: ** Comment from web user: digdug **

That would mean nant can't see the built dll. Did you update the build path in the project to your nant bin folder? Nant automatically looks for any dlls in its bin folder that has tasks in the name. If that's correct then maybe you need to update the reference to NAnt.Core.dll to the 0.92 version since that's what your running.

New Post: Edit Task

$
0
0
How to get the hum trigger replay value , when recursion for weekly?

Updated Wiki: Home

$
0
0
This project provides a wrapper for the Windows Task Scheduler. It aggregates the multiple versions, provides an editor and allows for localization.

This project's assemblies are available via NuGet. The main assembly is Task Scheduler Managed Wrapper and the UI assembly is
Task Scheduler Managed Wrapper UI Library.

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.
  • Maintain EmailAction and ShowMessageAction under Win8 where they have been deprecated.
  • 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 "custom" triggers under Win8 and later.
  • Numerous work-arounds and checks to compensate for base library shortcomings.
The project is based on work the originator started in January 2002 with the 1.0 library that is currently hosted on CodeProject.

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
Sample Code
There is a help file included with the download that provides an overview of the various classes. Below is a brief example of how to use the library from C#.

using System;
using Microsoft.Win32.TaskScheduler;

class Program
{
   staticvoid Main(string[] args)
   {
      // Get the service on the local machineusing (TaskService ts = new TaskService())
      {
         // 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);

         // Remove the task we just created
         ts.RootFolder.DeleteTask("Test");
      }
   }
}

If you really want to squeeze things into a single line of code (without any error handling):

new TaskService().AddTask("Test", new DailyTrigger(), new ExecAction("notepad.exe"));

For extended examples on how to the use the library, look in the source code area or look at the Examples Page. The library closely follows the Task Scheduler 2.0 Scripting classes. Microsoft has some examples on MSDN around it that may further help you understand how to use this library.

Commented Unassigned: Inheritance security rules violated while overriding member [12037]

$
0
0
I'm trying to write a NAnt extension that uses this library but I get this exception on my first method that loads the taskscheduler objects.

System.TypeLoadException: Inheritance security rules violated while overriding member: 'Microsoft.Win32.TaskScheduler.TaskService.System.Runtime.Serialization.ISerializab
le.GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)'. Security accessibility of the overriding method must mat
ch the security accessibility of the method being overriden.

I'm assuming this is related to NAnt dynamically loading the extension dll but I'm not sure how to get around it. Previously we were using the taskscheduler 1.0 library via NAnt without any issues.

```
public void test()
{
using (Microsoft.Win32.TaskScheduler.TaskService ts = new Microsoft.Win32.TaskScheduler.TaskService())
{
// Create a new task definition and assign properties
Microsoft.Win32.TaskScheduler.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 Microsoft.Win32.TaskScheduler.DailyTrigger { DaysInterval = 2 });

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

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

}
}
```
Comments: ** Comment from web user: dahall **

Ok. Changing the build directory, adding the reference to the Task Scheduler assembly to the project, and building the project solved the problem. Once I did that, I was able to execute CMD file and the task was created. I am using the assembly I attached earlier.

Source code checked in, #94864

Released: Release 2.3.1 (Mar 23, 2015)

$
0
0
Some bug fixes, better support for Windows 8 additions to core library, addition of Fluent syntax, and crontab syntax, since the 1.9.4 release. Since 2.0.3 release, added support for .NET 2.0 and 4.0, security handling, version compatibility handling (for connecting to up or down-stream versions), bug fixes, enhancements to history control and event trigger editor, compensation for deprecated email and message actions on Win8, and improved performance and marshalling. SeeSource Code for full details of changes. In 2.3.0, a more modern editor has been added as TaskOptionsEditor.

Download Descriptions
  • TaskScheduler.zip - Includes the base library (Microsoft.Win32.TaskScheduler.dll) with no UI code. Works with .NET 2.0 and higher. Separate assemblies for .NET 2.0 and 4.0. Add this assembly as a reference to interact with Task Scheduler on all systems with IE4 and later. This package is also available via NuGet with package name TaskScheduler.
  • TaskSchedulerEditor.zip - Includes the UI library (Microsoft.Win32.TaskSchedulerEditor.dll) with all supporting assemblies. Works with .NET 2.0 and higher. Separate assemblies for .NET 2.0 and 4.0. Add this assembly as a reference along with Microsoft.Win32.TaskScheduler.dll to get editor controls and dialogs that allow for viewing and editing tasks, triggers, actions, lists, etc. This package is also available viaNuGet with package nameTaskSchedulerEditor.
  • TaskSchedulerHelp.zip - Includes the Microsoft Help compatible help files for both the base and editor libraries. Extract all files and then run Install_TaskScheduler.bat to integrate the help.

Updated Release: Release 2.3.1 (Mar 23, 2015)

$
0
0
Some bug fixes, better support for Windows 8 additions to core library, addition of Fluent syntax, and crontab syntax, since the 1.9.4 release. Since 2.0.3 release, added support for .NET 2.0 and 4.0, security handling, version compatibility handling (for connecting to up or down-stream versions), bug fixes, enhancements to history control and event trigger editor, compensation for deprecated email and message actions on Win8, and improved performance and marshalling. See Source Code for full details of changes. In 2.3.0, a more modern editor has been added as TaskOptionsEditor.

Download Descriptions
  • TaskScheduler.zip - Includes the base library (Microsoft.Win32.TaskScheduler.dll) with no UI code. Works with .NET 2.0 and higher. Separate assemblies for .NET 2.0 and 4.0. Add this assembly as a reference to interact with Task Scheduler on all systems with IE4 and later. This package is also available via NuGet with package name TaskScheduler.
  • TaskSchedulerEditor.zip - Includes the UI library (Microsoft.Win32.TaskSchedulerEditor.dll) with all supporting assemblies. Works with .NET 2.0 and higher. Separate assemblies for .NET 2.0 and 4.0. Add this assembly as a reference along with Microsoft.Win32.TaskScheduler.dll to get editor controls and dialogs that allow for viewing and editing tasks, triggers, actions, lists, etc. This package is also available via NuGet with package name TaskSchedulerEditor.
  • TaskSchedulerHelp.zip - Includes the Microsoft Help compatible help files for both the base and editor libraries. Extract all files and then run Install_TaskScheduler.bat to integrate the help.

Updated Wiki: Home

$
0
0
This project provides a wrapper for the Windows Task Scheduler. It aggregates the multiple versions, provides an editor and allows for localization.

NuGet
This project's assemblies are available via NuGet.
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.
  • Maintain EmailAction and ShowMessageAction under Win8 where they have been deprecated.
  • 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 "custom" triggers under Win8 and later.
  • Numerous work-arounds and checks to compensate for base library shortcomings.
The project is based on work the originator started in January 2002 with the 1.0 library that is currently hosted on CodeProject.

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
Sample Code
There is a help file included with the download that provides an overview of the various classes. Below is a brief example of how to use the library from C#.

using System;
using Microsoft.Win32.TaskScheduler;

class Program
{
   staticvoid Main(string[] args)
   {
      // Get the service on the local machineusing (TaskService ts = new TaskService())
      {
         // 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);

         // Remove the task we just created
         ts.RootFolder.DeleteTask("Test");
      }
   }
}

If you really want to squeeze things into a single line of code (without any error handling):

new TaskService().AddTask("Test", new DailyTrigger(), new ExecAction("notepad.exe"));

For extended examples on how to the use the library, look in the source code area or look at the Examples Page. The library closely follows the Task Scheduler 2.0 Scripting classes. Microsoft has some examples on MSDN around it that may further help you understand how to use this library.

New Post: Edit Task

$
0
0
Can you clarify please? I'm not sure what a "hum trigger" is nor a "replay value" nor "recursion for weekly".

New Post: Edit Task

$
0
0
Descupe Google Translate was not as helpful this time .

Basically what I need is to get the value of the highlighted field in the image http://i.imgur.com/vYfxKG5.jpg

I tried using the command "MyTask.Definition.Triggers" and saw that the values ​​are stored in it but could not find the property that show me this value.

New Post: Edit Task

New Post: An exception of type 'System.Runtime.InteropServices.COMException' occurred in CubicOrange.Windows.Forms.ActiveDirectory.dll but was not handled in user code

$
0
0
I use TaskEditDialog. On Window 2008 when I try to open "Change User or Group" dialog I get message:
"the program cannot open the required dialog box because it cannot determine whether the computer named '' is joined to a domain"
After closing the dialog I get unhandled exception:
************** Exception Text **************
System.Runtime.InteropServices.COMException (0x80070005): IDsObjectPicker.Initialize failed
   at CubicOrange.Windows.Forms.ActiveDirectory.DirectoryObjectPickerDialog.Initialize()
   at CubicOrange.Windows.Forms.ActiveDirectory.DirectoryObjectPickerDialog.RunDialog(IntPtr hwndOwner)
   at System.Windows.Forms.CommonDialog.ShowDialog(IWin32Window owner)
   at Microsoft.Win32.TaskScheduler.HelperMethods.SelectAccount(IWin32Window parent, String targetComputerName, String& acctName, Boolean& isGroup, Boolean& isService, String& sid) in c:\spb.Common Components\TaskScheduler\TaskService\TaskEditor\HelperMethods.cs:line 18
   at Microsoft.Win32.TaskScheduler.TaskPropertiesControl.InvokeObjectPicker(String targetComputerName) in c:\spb.Common Components\TaskScheduler\TaskService\TaskEditor\TaskPropertiesControl.cs:line 632
   at Microsoft.Win32.TaskScheduler.TaskPropertiesControl.changePrincipalButton_Click(Object sender, EventArgs e) in c:\spb.Common Components\TaskScheduler\TaskService\TaskEditor\TaskPropertiesControl.cs:line 538
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
I use 2.3.1 version. Before that I used 2.2.2 and got the same message and exception on Windows 8.

New Post: An exception of type 'System.Runtime.InteropServices.COMException' occurred in CubicOrange.Windows.Forms.ActiveDirectory.dll but was not handled in user code

$
0
0
Also the dialog allows change only to current user. In other cases after ok pressing It always generate unhandled exception:
System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
   at Microsoft.Win32.TaskScheduler.V2Interop.ITaskFolder.RegisterTaskDefinition(String Path, ITaskDefinition pDefinition, Int32 flags, Object UserId, Object password, TaskLogonType LogonType, Object sddl)
   at Microsoft.Win32.TaskScheduler.TaskFolder.RegisterTaskDefinition(String Path, TaskDefinition definition, TaskCreation createType, String UserId, String password, TaskLogonType LogonType, String sddl) in c:\spb.Common Components\TaskScheduler\TaskService\TaskFolder.cs:line 404
   at Microsoft.Win32.TaskScheduler.TaskFolder.RegisterTaskDefinition(String Path, TaskDefinition definition) in c:\spb.Common Components\TaskScheduler\TaskService\TaskFolder.cs:line 369
   at Microsoft.Win32.TaskScheduler.Task.RegisterChanges() in c:\spb.Common Components\TaskScheduler\TaskService\Task.cs:line 1230
   at Microsoft.Win32.TaskScheduler.TaskEditDialog.okBtn_Click(Object sender, EventArgs e) in c:\spb.Common Components\TaskScheduler\TaskService\TaskEditor\TaskEditDialog.cs:line 280
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Is it right behavior?

New Post: Edit Task

$
0
0
You are looking for a WeeklyTrigger (see Documentation here) where you will set the DaysOfWeek property for all the days of the week needed and the WeeksInterval property for the interval.

New Post: An exception of type 'System.Runtime.InteropServices.COMException' occurred in CubicOrange.Windows.Forms.ActiveDirectory.dll but was not handled in user code

$
0
0
The first error is due to a problem with how that particular system is representing the computer to the domain. The prompt you get is from Windows. The COMException generated and not handled is a bug in the library which I have fixed and will be released in 2.3.2 shortly.

The second error is a permissions problem with the account used to initialize the TaskService. If no account was specified, it is the local account. That account does have permission to make changes to the task.

Source code checked in, #94917

$
0
0
* Fixed error handling for user dialog * Changed version to 2.3.2

New Post: Edit Task

$
0
0
Setting this value I found in the documentation , but I need is go the other way .
How to rebuild value of a task already created ?

New Post: [Solved] Edit Task

$
0
0
Task t = taskService.GetTask("MyTaskName");
// Assume there is only a single trigger
WeeklyTrigger wt = t.TaskDefinition.Triggers[0] as WeeklyTrigger;
if (wt != null)
   return wt.WeeksInterval;

New Post: [Solved] Edit Task

$
0
0
That's it!
You helped me a lot . Thank U.
Viewing all 2206 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>