I've tried the snippet of code:
Process p = new Process();
ProcessStartInfo info = new ProcessStartInfo("cmd.exe");
info.UseShellExecute = true;
info.Verb = "runas";
p.StartInfo = info;
p.Start();
using (StreamWriter sw = p.StandardInput)
{
if (sw.BaseStream.CanWrite)
{
sw.WriteLine("DISM.exe /Online /Add-Capability /CapabilityName:Microsoft.WebDriver~~~~0.0.1.0");
}
}
It successfully opens up a command prompt with administrative privileges but I can't seem to write into it use streamwriter. I know that this is because I don't have RedirectStandardInput set to true. If I do set this to true, I am able to write but my console loses its elevated privileges. My question is how can I write a command into the console when UseShellExecute is true?