1

I am starting a process with different user credential. I want that this process start as hidden. I am using fallowing code.But it doesn't work. The process starts as visible.

private void f(){
   try {                

      System.Security.SecureString ssPwd = new System.Security.SecureString();
      Process process = new Process();
      process.StartInfo.UseShellExecute = false;
      process.StartInfo.FileName = "app.exe";
      process.StartInfo.Arguments = "Params"; 
      process.StartInfo.LoadUserProfile = true;
      process.StartInfo.Domain = domain;                
      process.StartInfo.UserName = username;
      for (int x = 0; x < password.Length; x++) {
           ssPwd.AppendChar(password[x]);
      }
      process.StartInfo.Password = ssPwd;
      process.StartInfo.CreateNoWindow = true;
      process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
      process.Start();
      process.WaitForExit();                
   } catch (Exception ex) {
      Console.WriteLine("Exception occurred. " + ex.Message);
   }

}
doğan
  • 339
  • 1
  • 4
  • 15
  • 1
    This has already been answered [there](http://stackoverflow.com/a/33941764/7611303) – Aboc Feb 28 '17 at 14:21

0 Answers0