I tried to follow the example in the code in the Readme.md because it actually is what I need on my project. However, I experience a lot of issues with (1)Windows 10 security, and (2) a very few missing information on the example.
First, With Windows 10. I just wanted to share the required inbound rules to be enabled. But then again, I am no expert, and there might be missing information.
Remote Event Log Management (NP-In)
Remote Event Log Management (RPC)
Remote Event Log Management (RPC-EPMAP)
Windows Management Instrumentation (ASync-In)
Windows Management Instrumentation (DCOM-In)
Windows Management Instrumentation (WMI-In)
Network Discovery (NB-Name-In)
File and Printer Sharing (NB-Name-In)
Remote Service Management (NP-In)
Remote Service Management (RPC)
Remote Service Management (RPC-EPMAP)
Performance Logs and Alerts (DCOM-In)
Performance Logs and Alerts (Tcp-In)
Remote Scheduled Tasks Management (RPC)
Remote Scheduled Tasks Management (RPC-EMAP)
Next, I followed this:
`using (TaskService ts = new TaskService(@"\RemoteServer", "username", "domain", ""password))
{
// 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);
}`
.. and cool. I like how it was structured. Very readable. Unfortunately, I got an exception of {42,4}Userid: with the following stack trace:
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) at Microsoft.Win32.TaskScheduler.TaskFolder.RegisterTaskDefinition(String path, TaskDefinition definition)
.. Hmm.. not sure what happened there, eh? =)
Anyway, I tried to check ITaskFolder.RegisterTaskDefinition and it seems userId (or username) is required.. if, I'm not mistaken. So... I changed my code to the following:
`using (TaskService ts = new TaskService(@"\RemoteServer", "username", "domain", ""password))
{
// 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, TaskCreation.Create, "username");
}`
and voila! works like charm!
Kudos for this wrapper, man.
I tried to follow the example in the code in the Readme.md because it actually is what I need on my project. However, I experience a lot of issues with (1)Windows 10 security, and (2) a very few missing information on the example.
First, With Windows 10. I just wanted to share the required inbound rules to be enabled. But then again, I am no expert, and there might be missing information.
Next, I followed this:
`using (TaskService ts = new TaskService(@"\RemoteServer", "username", "domain", ""password)) { // Create a new task definition and assign properties TaskDefinition td = ts.NewTask(); td.RegistrationInfo.Description = "Does something";
.. and cool. I like how it was structured. Very readable. Unfortunately, I got an exception of {42,4}Userid: with the following stack trace:
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) at Microsoft.Win32.TaskScheduler.TaskFolder.RegisterTaskDefinition(String path, TaskDefinition definition)
.. Hmm.. not sure what happened there, eh? =)Anyway, I tried to check
ITaskFolder.RegisterTaskDefinition
and it seems userId (or username) is required.. if, I'm not mistaken. So... I changed my code to the following:`using (TaskService ts = new TaskService(@"\RemoteServer", "username", "domain", ""password)) { // Create a new task definition and assign properties TaskDefinition td = ts.NewTask(); td.RegistrationInfo.Description = "Does something";
and voila! works like charm! Kudos for this wrapper, man.
BTW, I'm running .NET Core 3.1