W
William Stacey [MVP]
Is this a bug in fx2? I expect they did not carry forward all the StartInfo
properties to api used with Username/Password. When you remove
UserName/password, the window does not show as expected.
private void button5_Click(object sender, EventArgs e)
{
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.Arguments = @"/c dir c:\windows\system32";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.RedirectStandardInput = true;
// *Note:
// With UserName/Password, Console window shows when should be hidden.
// Without UserName/Password, Consoel windows is hidden as expected.
p.StartInfo.UserName = "staceyw";
SecureString ss = new SecureString();
string pw = "password"; // Users password.
foreach ( char c in pw )
{
ss.AppendChar(c);
}
p.StartInfo.Password = ss;
p.Start();
StreamReader myStreamReader = p.StandardOutput;
string myString = myStreamReader.ReadToEnd();
Console.WriteLine(myString);
p.Close();
}
properties to api used with Username/Password. When you remove
UserName/password, the window does not show as expected.
private void button5_Click(object sender, EventArgs e)
{
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.Arguments = @"/c dir c:\windows\system32";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.RedirectStandardInput = true;
// *Note:
// With UserName/Password, Console window shows when should be hidden.
// Without UserName/Password, Consoel windows is hidden as expected.
p.StartInfo.UserName = "staceyw";
SecureString ss = new SecureString();
string pw = "password"; // Users password.
foreach ( char c in pw )
{
ss.AppendChar(c);
}
p.StartInfo.Password = ss;
p.Start();
StreamReader myStreamReader = p.StandardOutput;
string myString = myStreamReader.ReadToEnd();
Console.WriteLine(myString);
p.Close();
}