Start runas as subprocess and write password to stdin?
问题 I am trying to write a C# program that is supposed to call the runas tool from windows and input the password automatically. What I tried: Process runas = new Process(); runas.StartInfo.FileName = "runas"; runas.StartInfo.UseShellExecute = false; runas.StartInfo.RedirectStandardInput = true; runas.StartInfo.Arguments = "\"/user:domain\\username\" \"cmd.exe\""; runas.Start(); StreamWriter stream = runas.StandardInput; stream.WriteLine("our super secret password"); stream.Flush(); stream.Close(