In addition, I should not have to specify a password in the definition of the task if the "Run only when user is logged on" option is enabled because the user enters a password upon log on. When creating the task in the Task Scheduler manually, it does not prompt for a password.
How can I get this working so my application will start.
Comments: ** Comment from web user: dahall **
The code below should generate the exact format of the XML file you provided:
```
using (var ts = new TaskService())
{
var td = ts.NewTask();
td.RegistrationInfo.Description = "Launches Network Connection Manager upon login.";
td.Principal.RunLevel = TaskRunLevel.Highest;
td.Settings.DisallowStartIfOnBatteries = false;
td.Settings.StopIfGoingOnBatteries = false;
td.Settings.AllowHardTerminate = false;
td.Settings.IdleSettings.StopOnIdleEnd = false;
td.Settings.Hidden = true;
td.Settings.UseUnifiedSchedulingEngine = true;
td.Settings.ExecutionTimeLimit = TimeSpan.Zero;
td.Settings.Priority = System.Diagnostics.ProcessPriorityClass.Normal;
td.Actions.Add(@"M:\NetworkConnectionManager\NetworkConnectionManager.EXE",
null, @"M:\NetworkConnectionManager\");
td.Triggers.Add(new LogonTrigger { UserId = @"JEFFL-PC\GUEST" });
ts.RootFolder.RegisterTaskDefinition("TaskName", td, TaskCreation.CreateOrUpdate,
@"JEFFL-PC\GUEST", null, TaskLogonType.InteractiveToken, null);
}
```