Would somebody be able to tell me if what I'm attempting is possible??
My Issue is on Windows 10 (on windows 7 the below works)
I'd like to programatically create a an instance of "CMD.exe" launched in Administration mode whereby I specify the details of the admin user when creating the CMD process.
My end result is always the same:
- I can create the CMD.exe process
- The owner of the process is the administrator account I created it under (i can see this via task manager)
but the CMD.exe doesn't launch in administration mode (and that's my problem)
Here's my code — any help is greatly appreciated (I've spent far too long looking at this"). Any other articles I've read indicate how to create the process as an administrator but not to run it in Admin mode on Windows 10)
ProcessStartInfo p = new ProcessStartInfo();
p.WorkingDirectory = @"C:\Windows\System32";
p.FileName = @"C:\Windows\System32\cmd.exe";
p.UserName = "myUser";
p.Domain = "myDomain";
char[] password = { 'm', 'y', 'p', 'a', 's', 's'};
SecureString adminpassword = new SecureString();
foreach (char c in password)
{
adminpassword.AppendChar(c);
}
p.Password = adminpassword;
p.UseShellExecute = false;
p.Verb = "runas";
Process.Start(p);