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

Commented Unassigned: Error creating TaskDefinition on Window10 Home [12187]

$
0
0
When I try to create the TaskDefinition and see the XMlText of a System Task(SQM data sender)
'tk.Definition.XmlText' threw an exception of type __'System.OutOfMemoryException'__ exception.

exception base: "Insufficient memory to continue the execution of the program"

StackTrace:
at Microsoft.Win32.TaskScheduler.V2Interop.ITaskDefinition.get_XmlText()
at Microsoft.Win32.TaskScheduler.TaskDefinition.get_XmlText()

Code:
// Get the service on the local machine
TaskService ts = new TaskService(targetServer, userName, accountDomain, password);

__Note:__ The wrapper successfully created the Task Definitions of some 70 odd system tasks before failing at this one.
TaskName: SQM data sender

I am using the latest version of the wrapper.

Thanks in advance
Any help will be appreciated
Comments: ** Comment from web user: Karamveer **

@dahall: Thanks for the reply. I just wanted to know if this was thrown by the wrapper or by the base Microsoft library. I can just skip creating the task definitions of such tasks for the time being. This exception only occured for one particular (above mentioned) task and the rest are working fine.

Thanks again.


Commented Unassigned: Error creating TaskDefinition on Window10 Home [12187]

$
0
0
When I try to create the TaskDefinition and see the XMlText of a System Task(SQM data sender)
'tk.Definition.XmlText' threw an exception of type __'System.OutOfMemoryException'__ exception.

exception base: "Insufficient memory to continue the execution of the program"

StackTrace:
at Microsoft.Win32.TaskScheduler.V2Interop.ITaskDefinition.get_XmlText()
at Microsoft.Win32.TaskScheduler.TaskDefinition.get_XmlText()

Code:
// Get the service on the local machine
TaskService ts = new TaskService(targetServer, userName, accountDomain, password);

__Note:__ The wrapper successfully created the Task Definitions of some 70 odd system tasks before failing at this one.
TaskName: SQM data sender

I am using the latest version of the wrapper.

Thanks in advance
Any help will be appreciated
Comments: ** Comment from web user: dahall **

The exception was thrown when this wrapper calls into the COM Task Scheduler property to get the XML.

Commented Unassigned: Error using RegisterTaskDefinition on Windows 7 [12154]

$
0
0
A user of mine is having troubles when scheduling a task from his win2k3 server to a Win7
Everything always works from other servers and for other pc's.

The error he's getting is "The system cannot find the path specified. (Exception from HRESULT: 0x80070003)"
This happens when calling "RegisterTaskDefinition" using the following bit of code:

ts.RootFolder.RegisterTaskDefinition("Rester", tduser, TaskCreation.CreateOrUpdate, Domain + "\\" + User, password, TaskLogonType.Password);



Bit of context(test)
```
Try
{
WindowsImpersonationContext ImpersoToken = Impersonate(User, Domain, password);
if (ImpersoToken != null)
{
using (ImpersoToken)
{
using (TaskService ts = new TaskService(hostname, null, null, null, !IsVistaOrLater))
{
TaskDefinition tduser = ts.NewTask();
bool newVer = (ts.HighestSupportedVersion >= new Version(1, 2));
tduser.Actions.Add(new ExecAction("cmd", "/c set >> " + rootPath + "\\Test.txt", null));
tduser.Settings.DisallowStartIfOnBatteries = false;
tduser.Settings.StopIfGoingOnBatteries = false;

if (newVer)
{
tduser.Principal.RunLevel = TaskRunLevel.Highest; //v2.0
tduser.Settings.AllowDemandStart = true;
}
tduser.RegistrationInfo.Description = "Tester";

try
{
ts.RootFolder.RegisterTaskDefinition("Tester", tduser, TaskCreation.CreateOrUpdate, Domain + "\\" + User, password, TaskLogonType.Password);
ts.GetTask("Tester").Run();
}
catch (Exception ex)
{
//handleException(ex);
}
}
}
RevertToSelf();
}
}
catch (Exception ex)
{
//handleException(ex);
}
```
Comments: ** Comment from web user: dahall **

Make sure that the security settings on the remote system allow that user to access system tasks. There are a number of suggestions and links in the security section of the documentation to assist here.

New Post: How To Get the List of Network Connections [Conditions Tab]

$
0
0
I am trying to get the list of the Network Connections under the Conditions Tab.
However I am not able to find any object from the wrapper which allows me to retrieve the network connections list.

Any help will be appreciated
Thanks

New Post: How To Get the List of Network Connections [Conditions Tab]

$
0
0
The class used is not exposed publicly in the library. In the Source Code, look under the TaskEditor project, Native directory and find the NetworkProfile.cs class file. This is what you need. There is a static method on the class that retrieves the list of instances.
foreach (var item in Microsoft.Win32.NativeMethods.NetworkProfile.GetAllLocalProfiles())
   Console.WriteLine($"Network connection {item.Name} had an ID of {item.Id}");

New Post: How To Get the List of Network Connections [Conditions Tab]

$
0
0
Thanks. Its working perfectly now.

New Post: Deserialize Task Xml

$
0
0
Is there any way to deserialize the Task XML of the created task using wrapper ? I'm actually working on an application, developed with C#.

Does Task Definition contains some kind of property or method which would help me to do this ?


Thanks In Advance

New Post: Deserialize Task Xml

$
0
0
First you must have XML in the right format. This can be done via the library by capturing the output from an existing task via the Task.Xml property or by calling the task's Export method. If the task doesn't already exist, build up the TaskDefinition as outlined in the documentation and then capture the TaskDefinition instance's XmlText property. Note that all these suggestions return Xml using the schema defined by Microsoft for tasks.

Once you have the properly formatted Xml, you can create tasks by:
  1. Call the TaskService instance's NewTaskFromFile method passing the file path and then registering the returned TaskDefintion.
  2. Get an instance to the TaskFolder in which you want to create the task and call its RegisterTask method passing in the xml (not the file) as the second parameter.
  3. Get an instance to the TaskFolder in which you want to create the task and call its ImportTask method passing in the xml file path as the second parameter.

New Post: Deserialize Task Xml

$
0
0
@dahall: Thanks for the reply.
But I don't want to create tasks using the XML. I have created a task and stored its Xml(using Task.Xml) in a sql db. I am retrieving this XML.
So, now the problem is that I want to deserialize this XML. So is there any method provided by the wrapper to deserialize this XML ?

Thanks again

New Post: Deserialize Task Xml

$
0
0
Yes, step 1 above will accomplish what you are asking. It only creates a TaskDefinition and does not register it.

Closed Unassigned: Error creating TaskDefinition on Window10 Home [12187]

$
0
0
When I try to create the TaskDefinition and see the XMlText of a System Task(SQM data sender)
'tk.Definition.XmlText' threw an exception of type __'System.OutOfMemoryException'__ exception.

exception base: "Insufficient memory to continue the execution of the program"

StackTrace:
at Microsoft.Win32.TaskScheduler.V2Interop.ITaskDefinition.get_XmlText()
at Microsoft.Win32.TaskScheduler.TaskDefinition.get_XmlText()

Code:
// Get the service on the local machine
TaskService ts = new TaskService(targetServer, userName, accountDomain, password);

__Note:__ The wrapper successfully created the Task Definitions of some 70 odd system tasks before failing at this one.
TaskName: SQM data sender

I am using the latest version of the wrapper.

Thanks in advance
Any help will be appreciated

New Post: Deserialize Task Xml

$
0
0
Okay. And will it work with the Tasks present on some remote machine in my domain ? I mean I am able to create tasks on the remote machines, so how I do make sure that the tasks with their XML (on remote machines) can be deserialized as well ?
Thanks for replying and taking time to solve all the queries .
Really appreciate it

Source code checked in, #97728

$
0
0
* Rolled to 2.4.1 * Added error handling into RegisterTaskDefinition

New Post: Deserialize Task Xml

$
0
0
It will work as long as the XML have extracted complies with all the versions of Windows in your environment. You can do a few things to ensure this:
  1. Use the Task Scheduler applet from Windows on the oldest version of Windows in the environment to export the XML for your task.
  2. Use the same applet on any version, but make sure the OS selected on the first tab is the oldest in your environment.
  3. In the library, use the TaskDefintion's LowestSupportedVersion to confirm it complies or use the Validate method to get a list of reasons it doesn't.

New Post: TaskOptionsEditor

$
0
0
Hi all, is this UI version working at all? I ask before I start getting into the source code and trying to find what may be happening. I just don't get any of the controls filled with the data (I tried the exact same code with TaskEditorDialog instead and it seems to work). Below is the code I'm using.
        Using TS As New TaskService()
            Dim aTaskEditDialog As TaskOptionsEditor
            Dim aTaskDef As TaskDefinition = TS.NewTask
            aTaskDef.XmlText = tbTaskDef.Text 'this can be blank, but usually have the XML from a TaskDefinition.XML
            Dim aTaskOptionsEditor As TaskOptionsEditor = New TaskOptionsEditor(TS, aTaskDef, True, False)
            aTaskEditDialog = New TaskOptionsEditor(TS, aTaskDef, True, False)
            aTaskEditDialog.TaskFolder = "\" + TScourmanService.TASK_SCHEDULER_FOLDER
            aTaskEditDialog.TaskName = PlugInDef.Name 'PlugInDef.Name is a string
            'aTaskEditDialog.ReinitializeControls() 'not doing aything
            If aTaskEditDialog.ShowDialog() = Windows.Forms.DialogResult.OK Then
                'aTaskEditDialog always appears empty, not even the task name shows 
                tbTaskDef.Text = FormatXML(aTaskEditDialog.TaskDefinition.XmlText)
            End If
            'remove the task we just added - we don't want this task registered in the client machine
            TS.GetFolder("\" + TScourmanService.TASK_SCHEDULER_FOLDER).DeleteTask(PlugInDef.Name, False)
        End Using


New Post: TaskOptionsEditor

$
0
0
I will try this code and let you know how to fix or I will fix the code. You actually may be the first one to use this new concept editor. Thanks for the alert.

New Post: TaskOptionsEditor

$
0
0
Thanks, Dahall, I can(and I'm willing to) help too, except the projects are in VS 2015, and cannot read them completely (using 2013 gets stuck with ITaskHandler COM Server Project Template). I also have found some problems with TaskEditorDialog (for example, it does not seem to modify the task definition to reflect that you selected the option to delete the task immediately if the task is not scheduled to be run again!). I'm writing an application that does a fair amount of work with the task scheduler using your library, so I might be able to do some basic debugging to the UI components, if you can provide a version that I can compile using VS 2013.

Created Issue: TaskOptionsEditor [12198]

$
0
0
Hi all, is this UI version working at all? I ask before I start getting into the source code and trying to find what may be happening. I just don't get any of the controls filled with the data (I tried the exact same code with TaskEditorDialog instead and it seems to work). Below is the code I'm using.
```
Using TS As New TaskService()
Dim aTaskEditDialog As TaskOptionsEditor
Dim aTaskDef As TaskDefinition = TS.NewTask
aTaskDef.XmlText = tbTaskDef.Text 'this can be blank, but usually have the XML from a TaskDefinition.XML
Dim aTaskOptionsEditor As TaskOptionsEditor = New TaskOptionsEditor(TS, aTaskDef, True, False)
aTaskEditDialog = New TaskOptionsEditor(TS, aTaskDef, True, False)
aTaskEditDialog.TaskFolder = "\" + TScourmanService.TASK_SCHEDULER_FOLDER
aTaskEditDialog.TaskName = PlugInDef.Name 'PlugInDef.Name is a string
'aTaskEditDialog.ReinitializeControls() 'not doing aything
If aTaskEditDialog.ShowDialog() = Windows.Forms.DialogResult.OK Then
'aTaskEditDialog always appears empty, not even the task name shows
tbTaskDef.Text = FormatXML(aTaskEditDialog.TaskDefinition.XmlText)
End If
'remove the task we just added - we don't want this task registered in the client machine
TS.GetFolder("\" + TScourmanService.TASK_SCHEDULER_FOLDER).DeleteTask(PlugInDef.Name, False)
End Using
```

Edited Issue: TaskOptionsEditor [12198]

$
0
0
Hi all, is this UI version working at all? I ask before I start getting into the source code and trying to find what may be happening. I just don't get any of the controls filled with the data (I tried the exact same code with TaskEditorDialog instead and it seems to work). Below is the code I'm using.
```
Using TS As New TaskService()
Dim aTaskEditDialog As TaskOptionsEditor
Dim aTaskDef As TaskDefinition = TS.NewTask
aTaskDef.XmlText = tbTaskDef.Text 'this can be blank, but usually have the XML from a TaskDefinition.XML
Dim aTaskOptionsEditor As TaskOptionsEditor = New TaskOptionsEditor(TS, aTaskDef, True, False)
aTaskEditDialog = New TaskOptionsEditor(TS, aTaskDef, True, False)
aTaskEditDialog.TaskFolder = "\" + TScourmanService.TASK_SCHEDULER_FOLDER
aTaskEditDialog.TaskName = PlugInDef.Name 'PlugInDef.Name is a string
'aTaskEditDialog.ReinitializeControls() 'not doing aything
If aTaskEditDialog.ShowDialog() = Windows.Forms.DialogResult.OK Then
'aTaskEditDialog always appears empty, not even the task name shows
tbTaskDef.Text = FormatXML(aTaskEditDialog.TaskDefinition.XmlText)
End If
'remove the task we just added - we don't want this task registered in the client machine
TS.GetFolder("\" + TScourmanService.TASK_SCHEDULER_FOLDER).DeleteTask(PlugInDef.Name, False)
End Using
```

New Post: TaskOptionsEditor

$
0
0
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Viewing all 2206 articles
Browse latest View live


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