Console App

K

Ken Kast

Is there any way programmatically to have a console app start in a minimized
window?
 
V

ViRi

Here is an example i created for someone else in this newsgroup, it
starts CMD.exe (console), and has it run ipconfig /renew without the
window itself showing up, you can look at the code & change it to suit
your needs.

private void start()
{
System.Diagnostics.Process p = new
System.Diagnostics.Process();
System.IO.StreamWriter sw;
System.IO.StreamReader sr;
System.IO.StreamReader err;

System.Diagnostics.ProcessStartInfo psI = new
System.Diagnostics.ProcessStartInfo("cmd");
psI.UseShellExecute = false;
psI.RedirectStandardInput = true;
psI.RedirectStandardOutput = true;
psI.RedirectStandardError = true;
psI.CreateNoWindow = true;
p.StartInfo = psI;

p.Start();
sw = p.StandardInput;
sr = p.StandardOutput;
err = p.StandardError;

sw.AutoFlush = true;
sw.WriteLine("ipconfig /renew");
sw.Close();

System.Diagnostics.Debug.WriteLine("Returned Info: " +
sr.ReadToEnd());
System.Diagnostics.Debug.WriteLine("Errors: " +
err.ReadToEnd());
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top