title: Create windows Tasks programmatically using ASP.net and C# and task could not start
body: <p>I need to create windows Tasks programmatically using ASP.net and C# (Windows Server 2003).
  When I use following code:</p>
  
  <pre><code>Process p = new Process();
  p.StartInfo.FileName = "schtasks.exe";
  p.StartInfo.Arguments = " /create /tn MyTask /tr notepad.exe /sc DAILY /st 10:00:00 /ru myUsername /rp myPassword ";
  p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
  p.Start();
  p.WaitForExit();
  </code></pre>
  
  <p>It create task successfully, but task don’t execute and says “Could not start”</p>
  
  <p>Also in log file it says:
  "MyTask.job" (notepad.exe) 10/9/2012 10:00 PM ** ERROR **
  The attempt to retrieve account information for the specified task failed; therefore, the task did not run. Either an error occurred, or no account information existed for the task.
  The specific error is: 0x8004130f: No account information could be found in the Task Scheduler security database for the task indicated.</p>
  
  <p>When I go through Control panel/Scheduled tasks and right click on my task and set my password again, my task will be run successfully in next time.
  How can I do? 
  Also when I change my code to:</p>
  
  <pre><code>    Process p = new Process();
      p.StartInfo.FileName = "schtasks.exe";
      p.StartInfo.Arguments = " /create /tn MyTask /tr notepad.exe /sc DAILY /st 10:00:00 /s system /u myUsername /p myPassword ";
      p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
      p.Start();
      p.WaitForExit();
  </code></pre>
  
  <p>It makes this error:</p>
  
  <p>ERROR:  Passing the user credential on local connection</p>