title: Registering a new task in C# is not working
body: <p>I want to register a new task. My app has admin privileges:</p>
  
  <pre><code>&lt;requestedExecutionLevel level="requireAdministrator" uiAccess="false" /&gt;
  </code></pre>
  
  <p>I have tried to find something on the Internet, but there are so many examples that tell me I'm doing it right.<br>
  Here's an exception I'm getting:</p>
  
  <blockquote>
    <p>COMException was caught Account restrictions are preventing this user
    from signing in. For example: blank passwords aren't allowed, sign-in
    times are limited or a policy restriction has been enforced.
    (Exception from HRESULT: 0x8007052F)</p>
  </blockquote>
  
  <p>I don't know why it's not working for me...</p>
  
  <p>Here's my method:</p>
  
  <pre><code>private void CreateTask()
  {
      using (var ts = new TaskService())
      {
          string computerName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
  
          TaskDefinition td = ts.NewTask();
          td.RegistrationInfo.Date = DateTime.Now;
          td.RegistrationInfo.Author = computerName;
          td.RegistrationInfo.Description = "This task is awesome.";
  
          var trigger = new DailyTrigger(1)
          {
              Enabled = true,
              StartBoundary = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + "T05:00:00")
          };
          td.Triggers.Add(trigger);
  
          td.Principal.Id = "Author";
          td.Principal.UserId = computerName;
          td.Principal.LogonType = TaskLogonType.Password;
          td.Principal.RunLevel = TaskRunLevel.Highest;
  
          td.Settings.MultipleInstances = TaskInstancesPolicy.IgnoreNew;
          td.Settings.DisallowStartIfOnBatteries = true;
          td.Settings.StopIfGoingOnBatteries = true;
          td.Settings.AllowHardTerminate = true;
          td.Settings.StartWhenAvailable = false;
          td.Settings.RunOnlyIfNetworkAvailable = false;
          td.Settings.IdleSettings.StopOnIdleEnd = true;
          td.Settings.IdleSettings.RestartOnIdle = false;
          td.Settings.AllowDemandStart = true;
          td.Settings.Enabled = true;
          td.Settings.Hidden = false;
          td.Settings.RunOnlyIfIdle = false;
          td.Settings.WakeToRun = false;
          td.Settings.ExecutionTimeLimit = TimeSpan.FromHours(8);
          td.Settings.Priority = (ProcessPriorityClass) 7;
  
          td.Actions.Add(new ExecAction(Path.Combine(Config.MainDir, "Scripts", "starter.bat"),
                                        workingDirectory: Path.Combine(Config.MainDir, "Scripts")));
  
          ts.RootFolder.RegisterTaskDefinition("My Task", td);
      }
  }
  </code></pre>