943,667 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 11424
  • C# RSS
Oct 19th, 2007
0

call cmd processes and keeping them cmd window

Expand Post »
I've been able to call a cmd process to run a batch file. It runs but I have no idea what it does bec' the window opens and closes too fast. I've used .WaitForExit(), but it doesn't help. I've been looking for more help and can find anything specific. I can't tell if my batch file runs or not and where the output redirects too. Any help would be greatly appreciated. Thanks.

Gabe
Similar Threads
Reputation Points: 10
Solved Threads: 1
Newbie Poster
GRaymer is offline Offline
13 posts
since Sep 2007
Oct 19th, 2007
0

Re: call cmd processes and keeping them cmd window

You remind me with graduation project days

C# Syntax (Toggle Plain Text)
  1. public void GenerateKeyFile(string command)
  2. {
  3. ProcessStartInfo PSI = new ProcessStartInfo("cmd.exe");
  4. PSI.RedirectStandardInput = true;
  5. PSI.RedirectStandardOutput = true;
  6. PSI.RedirectStandardError = true;
  7. PSI.UseShellExecute = false;
  8. Process p = Process.Start(PSI);
  9. System.IO.StreamWriter SW = p.StandardInput;
  10. System.IO.StreamReader SR = p.StandardOutput;
  11. SW.WriteLine(command);
  12. SW.Close();
  13. }
Featured Poster
Reputation Points: 480
Solved Threads: 276
Postaholic
Ramy Mahrous is offline Offline
2,189 posts
since Aug 2006
Oct 26th, 2007
0

Re: call cmd processes and keeping them cmd window

ok, quick and dirty, to be removed before building release - used to help me in my student years. Last line of code is :
Console.ReadLine();

that will wait until you kill the console.
Reputation Points: 12
Solved Threads: 1
Newbie Poster
tostrinj is offline Offline
20 posts
since Jul 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: open file in same folder as application
Next Thread in C# Forum Timeline: Displaying an XML table





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC