471,306 Members | 1,380 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,306 software developers and data experts.

Console App

Is there any way programmatically to have a console app start in a minimized
window?
Dec 6 '05 #1
1 1420
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());
}

Dec 6 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

19 posts views Thread by Dave | last post: by
5 posts views Thread by Publicjoe | last post: by
17 posts views Thread by MumboJumbo | last post: by
5 posts views Thread by portroe | last post: by
3 posts views Thread by julianmoors | last post: by
1 post views Thread by John Wright | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.