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

Commented Issue: Use a Group Managed service account to run a schedule task and make it "Run whether user is logged on or not"? [12362]

$
0
0
These two ways are not working, here is my test code, I test it on windows server 2012R2:
```
using System;
using System.Runtime.InteropServices;
using Microsoft.Win32.TaskScheduler;

namespace WrapperDemo
{
internal static class Program
{
public static void Main(string[] args)
{
try
{
var action = new ExecAction(@"C:\PowerSlim\test.cmd");
var trigger = new DailyTrigger(1);
trigger.StartBoundary = DateTime.Today.AddHours(20);
TaskService.Instance.AddTask("msaTask", trigger, action, @"er\zz$", "", TaskLogonType.Password);
}
catch (COMException exception)
{
Console.WriteLine(exception.ToString());
}

}
}
}

```
I got exception like following on the console output:

System.Runtime.InteropServices.COMException (0x8007052E): The username or password is incorrect. (Exception from HRESULT: 0x8007052E)
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.TaskService.AddTask(String path, Trigger trigger, Action action, String UserId, String Password, TaskLogonType LogonType)
at WrapperDemo.Program.Main(String[] args) in C:\Users\lhuang2\Documents\Visual Studio 2015\Projects\WrapperDemo\WrapperDemo\Program.cs:line 20
Comments: ** Comment from web user: alvin_chen **

@dahall, I tried v4.5.2 in the attachment, it works.
But we need to work in .net framework 4.0, and we use NuGet to manage this library, so hope this fixing could be available soon. Thanks!


Viewing all articles
Browse latest Browse all 2206

Trending Articles



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