title: RunAs and C# process - impersonate user credentials not working
body: <p>I want to create a simple application to launch another application under different credentials.</p>
  
  <p>Both application are on my laptop which is not on the domain. I need to run SSMS using a domain user credentials.</p>
  
  <p>When I use the following runas command, it works:</p>
  
  <pre><code>runas.exe /netonly /user:domain\username /password:mypass "C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\Ssms.exe"
  </code></pre>
  
  <p>The following code IS NOT working : </p>
  
  <pre><code>        var file = @"C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\Ssms.exe";
          var sspw = new SecureString();
          foreach (var c in "mypass" sspw.AppendChar(c);
  
          var proc = new Process();
          proc.StartInfo.UseShellExecute = false;
          proc.StartInfo.WorkingDirectory = Path.GetDirectoryName(file);
          proc.StartInfo.FileName = Path.GetFileName(file);
          proc.StartInfo.Arguments = "";
          proc.StartInfo.Domain = "domain";
          proc.StartInfo.UserName = "username";
          proc.StartInfo.Password = sspw;
          proc.StartInfo.LoadUserProfile = true;
  
          proc.Start();
  </code></pre>
  
  <p>The exception message is:</p>
  
  <pre><code>Logon failure: unknown user name or bad password
  </code></pre>