H
Huey
I need to hide the new window started from the code below. If I run as is,
the window is visible. If I comment out the code that sets a different user,
domain, and password the window is hidden as desired. Does anyone know if
there is a known issue with hiding a process window when you run it as a
different user? Do you have any suggestions to work around this problem?
Thank you.
Process proc = new Process();
proc.EnableRaisingEvents = false;
proc.StartInfo.FileName = "cmd.exe";
proc.StartInfo.Arguments = "/C time /T";
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.Domain = CurrentAdmin.Domain;
proc.StartInfo.UserName = CurrentAdmin.UserID;
proc.StartInfo.Password = CurrentAdmin.Password;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.RedirectStandardInput = true;
proc.StartInfo.RedirectStandardError = true;
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
proc.Start();
StreamReader myOutput = proc.StandardOutput;
proc.WaitForExit();
while (myOutput.EndOfStream == false)
{
string Inline;
Inline = myOutput.ReadLine();
Response = Response + Inline + Environment.NewLine;
}
MessageBox.Show(Response);
the window is visible. If I comment out the code that sets a different user,
domain, and password the window is hidden as desired. Does anyone know if
there is a known issue with hiding a process window when you run it as a
different user? Do you have any suggestions to work around this problem?
Thank you.
Process proc = new Process();
proc.EnableRaisingEvents = false;
proc.StartInfo.FileName = "cmd.exe";
proc.StartInfo.Arguments = "/C time /T";
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.Domain = CurrentAdmin.Domain;
proc.StartInfo.UserName = CurrentAdmin.UserID;
proc.StartInfo.Password = CurrentAdmin.Password;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.RedirectStandardInput = true;
proc.StartInfo.RedirectStandardError = true;
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
proc.Start();
StreamReader myOutput = proc.StandardOutput;
proc.WaitForExit();
while (myOutput.EndOfStream == false)
{
string Inline;
Inline = myOutput.ReadLine();
Response = Response + Inline + Environment.NewLine;
}
MessageBox.Show(Response);