使用c#中的不同凭据启动隐藏进程

时间:2017-02-28 13:53:18

标签: c# .net process hidden credentials

我正在使用不同的用户凭据启动流程。我希望这个过程从隐藏开始。我正在使用fallowing code.But它不起作用。该过程从可见开始。

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);
   }

}

0 个答案:

没有答案