Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void btnADMIN_Click(object sender, RoutedEventArgs e)
- {
- RunAs("administrator", "domein", "secret", "\\\\ps01\\aps\\stl\\ictform.exe", Environment.UserName);
- }
- static void RunAs(string UserName, string DomainName, string Password, string ExePath, string Arguments)
- {
- Process proc = new Process();
- if (!String.IsNullOrEmpty(DomainName))
- proc.StartInfo.Domain = DomainName;
- proc.StartInfo.UserName = UserName;
- proc.StartInfo.LoadUserProfile = true;
- proc.StartInfo.FileName = ExePath;
- proc.StartInfo.Arguments = Arguments;
- //if (!String.IsNullOrEmpty(WorkingDir))
- // proc.StartInfo.WorkingDirectory = WorkingDir;
- proc.StartInfo.Password = new System.Security.SecureString();
- foreach (char c in Password)
- proc.StartInfo.Password.AppendChar(c);
- proc.StartInfo.UseShellExecute = false;
- proc.Start();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement