Closed Slavok47 closed 1 year ago
Check info at #494
I don't think it's a permissions issue, the error is in the line
TaskService service = new TaskService();
I tried to process it
try
{
TaskService service = new TaskService();
}
catch (Exception x)
{
output log
}
but it doesn't work, I don't even understand why
The problem is solved, now the task is created, but on behalf of the system, it needs to be run on behalf of the user logged into the system
Problem solved, everything works, I don't know how much is correct
ManagementObjectSearcher searcher_User = new ManagementObjectSearcher("SELECT UserName FROM Win32_ComputerSystem");
ManagementObjectCollection collection = searcher_User.Get();
string userName = (string)collection.Cast<ManagementBaseObject>().First()["UserName"];
TaskService.Instance.RootFolder.RegisterTaskDefinition(taskName, task, TaskCreation.CreateOrUpdate, userName, null, TaskLogonType.None).Run();
I can not figure out the launch and services, tell me what the problem is
when using WinForm everything is fine, the service is used from LocalSystem