Click here to Skip to main content
16,005,162 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
good morning, good afternoon, good evening whereever you are,

i've written a small application which executes the old dos-programs bascom, link and lib.
i did it 'cause i have to work over some old basic programs and that can be quite
nasty with windows, because the development tools didn't support filepathes.
as all worked fine i decided to integrate the execution of debug.exe and that doesn't work at all.
starting the process executes debug within the dosbox, but shows no prompt (which is this : -) and shows nothing i'm typing.
when i click debug in the explorer everthing's ok, so why doesn't c# process work ?

any ideas ?

franz
Posted
Comments
#realJSOP 2-Dec-11 8:03am    
We need to see how you're configuring the Process object to run Debug.exe.

To start with, there is not such thing as "dosbox" and "old dos-programs" unless you are talking about obsolete systems not based on NT. Something else: "…because the development tools didn't support filepathes" — who told you so?

What are you talking about is just a console application. I bet this is a regular Windows 32- or 64-bit application, without a tiny bit of DOS. Now, no wonder that you don't have a prompt or anything like that unless you don't write it in your console. If you want the regular console input without console, you have to emulate it somehow. To do so, you need to use System.Diagnostics.Process.Start(ProcessStartInfo), redirect StandardInput stream and write your input data into this stream on every step of debugger or other tool. To get output, you will need to redirect StandardOutput and StandardError as well. This is not so simple.

See:
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx[^],
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.standardinput.aspx[^] (some code sample here),
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.standarderror.aspx[^],
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.standardoutput.aspx[^] (and here),
http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.aspx[^].

—SA
 
Share this answer
 
Comments
Manoj K Bhoir 2-Dec-11 10:12am    
My 5!
Sergey Alexandrovich Kryukov 2-Dec-11 10:30am    
Thank you, Manoj.
--SA
thatraja 2-Dec-11 10:17am    
Big 5!
Sergey Alexandrovich Kryukov 2-Dec-11 10:29am    
Big thanks, Raja.
--SA
This code snippet which was extracted from here :
http://stackoverflow.com/questions/186822/capturing-console-output-from-a-net-application-c[^]


shows the output of a ping command :
C#
Process compiler = new Process();
compiler.StartInfo.FileName = "ping.exe";
compiler.StartInfo.Arguments = "localhost";
compiler.StartInfo.UseShellExecute = false;
compiler.StartInfo.RedirectStandardOutput = true;
compiler.Start();

Console.WriteLine(compiler.StandardOutput.ReadToEnd());

compiler.WaitForExit();



I think you can adapt it to your problem with a very little manipulation.

Hope it helps.
 
Share this answer
 
Comments
fheyn 3-Dec-11 12:23pm    
high,

thanks for the response.

as i pointed out above, executing the compiler and linker work fine.

however debug.exe doesn't. i've played around with RedirectStandardOutput and

RedirectStandardInput but debug's behavior stayes the same.
Amir Mahfoozi 4-Dec-11 0:03am    
If the debug.exe gives you its output immediately in command prompt then its very probably that you can catch its output in your program. But you must make sure that the program terminates because you will get the output when it finishes. so may be the problem is that it doesn't finish so you can't get the output in your program.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900