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

New Post: cannot creating a task without running app as admin

$
0
0
when trying to create tasks I get access denied unless the program is stated as admin. the user is a local admin on the system, the task is being created on the same system, and the task is to be run as a different user. below is the gist of the code, please let me know
using (TaskService ts = new TaskService())
{
           TimeTrigger start = new TimeTrigger { StartBoundary = dateTime1.Value };
            TaskDefinition td = ts.NewTask();
            td.Triggers.Add(start);
            td.Principal.RunLevel = TaskRunLevel.Highest;
            td.Settings.Compatibility = TaskCompatibility.V2_2;
            td.Actions.Add(new ExecAction(Environment.GetCommandLineArgs()[0], cmd, null));
            ts.RootFolder.RegisterTaskDefinition("Task Name", td, TaskCreation.Create, username, password, TaskLogonType.Password);
}
any ideas?

Viewing all articles
Browse latest Browse all 2206

Trending Articles



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