Advertisement
Guest User

Untitled

a guest
Jun 1st, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.06 KB | None | 0 0
  1.  private void btnADMIN_Click(object sender, RoutedEventArgs e)
  2.         {
  3.             RunAs("administrator", "BE", "04atlantis", "\\\\brups01\\apps\\stal\\ictform.exe", Environment.UserName);
  4.         }
  5.  
  6.         static void RunAs(string UserName, string DomainName, string Password, string ExePath, string Arguments)
  7.         {
  8.             Process proc = new Process();
  9.  
  10.             if (!String.IsNullOrEmpty(DomainName))
  11.                 proc.StartInfo.Domain = DomainName;
  12.             proc.StartInfo.UserName = UserName;
  13.  
  14.             proc.StartInfo.LoadUserProfile = true;
  15.  
  16.             proc.StartInfo.FileName = ExePath;
  17.             proc.StartInfo.Arguments = Arguments;
  18.              
  19.             //if (!String.IsNullOrEmpty(WorkingDir))
  20.             //  proc.StartInfo.WorkingDirectory = WorkingDir;
  21.  
  22.             proc.StartInfo.Password = new System.Security.SecureString();
  23.             foreach (char c in Password)
  24.                 proc.StartInfo.Password.AppendChar(c);
  25.  
  26.             proc.StartInfo.UseShellExecute = false;
  27.  
  28.             proc.Start();
  29.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement