3 Replies - 2718 Views - Last Post: 10 February 2010 - 12:06 PM Rate Topic: -----

#1 paxamime  Icon User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 10
  • Joined: 25-January 10

(Resolved) Need to start a command line application and keep it open

Posted 10 February 2010 - 11:40 AM

Currently I have a GUI application that I use to execute other applications. Some of the programs that I need to start are command line applications. The problem that I am having is that these programs will open and then immediately close, but I need them to stay open. I would greatly appreciate any help on this. After a week of trying to figure it out I am stumped. Here is what I currently have:

          
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.WorkingDirectory = (Directory.GetCurrentDirectory() + "\\Error Code Lookup Tool\\");
proc.EnableRaisingEvents = false;
proc.StartInfo.FileName = "Err.exe";
proc.Start();



I have tried multiple variations on this but so far have been unsuccessful. I feel like it is something simple that I am missing but I am lost.

This post has been edited by paxamime: 10 February 2010 - 12:07 PM


Is This A Good Question/Topic? 0
  • +

Replies To: (Resolved) Need to start a command line application and keep it open

#2 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,960
  • Joined: 21-March 08

Re: (Resolved) Need to start a command line application and keep it open

Posted 10 February 2010 - 11:53 AM

Do you have control over those other command-line applications? If no, there is nothing you can do about it. It is designed to run code. Once it gets finished running the code, it closes. If you can't change the code of those applications, you can't make them stay open.
Was This Post Helpful? 0
  • +
  • -

#3 paxamime  Icon User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 10
  • Joined: 25-January 10

Re: (Resolved) Need to start a command line application and keep it open

Posted 10 February 2010 - 11:58 AM

View Posteclipsed4utoo, on 10 February 2010 - 10:53 AM, said:

Do you have control over those other command-line applications? If no, there is nothing you can do about it. It is designed to run code. Once it gets finished running the code, it closes. If you can't change the code of those applications, you can't make them stay open.


No I don't have control over the other applications, but if I manually open a command prompt and then launch the same executable it will launch correctly.

To clarify this a little bit it would be similar to opening a command prompt, running ipconfig /all but then keeping the same console window open after it finishes.
Was This Post Helpful? 0
  • +
  • -

#4 paxamime  Icon User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 10
  • Joined: 25-January 10

Re: (Resolved) Need to start a command line application and keep it open

Posted 10 February 2010 - 12:06 PM

And is typical with things like this, I just found the answer to my own question. For anyone else looking to do this same thing here is the answer:

System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.WorkingDirectory = (Directory.GetCurrentDirectory() + "\\Error Code Lookup Tool\\");
proc.EnableRaisingEvents = false;
proc.StartInfo.FileName = "cmd.exe";
proc.StartInfo.Arguments =  "/k err.exe";
proc.Start();



Was This Post Helpful? 0
  • +
  • -

Page 1 of 1