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?