Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int ProcessStartOk333(string path, string name, Boolean start)
- {
- string processName = name;
- var processExists = Process.GetProcesses().Any(p => p.ProcessName == processName);
- var process = Process.GetProcesses().FirstOrDefault(p => p.ProcessName == processName);
- if (!processExists && start == true)
- {
- string processPath = path;
- var startInfo = new ProcessStartInfo(processPath)
- { Verb = "runas" };
- startInfo.Password = ReadPassword(textBox2.Text); //попытка ввести пароль администратора таким образом
- startInfo.UserName = textBox3.Text;
- Process.Start(startInfo); //есть запуск
- // MessageBox.Show("запустили");
- }
- }
- public static SecureString ReadPassword(string password)
- {
- SecureString secPass = new SecureString();
- for (int i = 0; i < password.Length; i++)
- secPass.AppendChar(password[i]);
- return secPass;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement