Executing Old 16 Bit DOS Apps from C# via System.Diagnostics.Process 
Author Message
 Executing Old 16 Bit DOS Apps from C# via System.Diagnostics.Process

Here is a piece of code from a class I have created.  It calls an old
DOS app (ioncap.exe) with the ?piped? input shown.  The command works
fine from the command line, but when I run the code below in my C#.NET
app it appears to execute (The Exited event fires and prints the debug
message), but no output from the app is in the execution directory (a
file).

Here is a copy of the batch file fls.txt:
        i3.txt
        out.txt

Here is the code used to call the app.

private System.Diagnostics.Process procIonCap;

private void InitializeComponent()
{
        this.components = new System.ComponentModel.Container ();
        this.procIonCap = new System.Diagnostics.Process ();



        procIonCap.Exited += System.EventHandler(this.procIonCap_Exited);
        procIonCap.StartInfo.Arguments = "<fls.txt";
        procIonCap.StartInfo.FileName =
                "C:\\C#.NET\\DxHelper\\IONCAP\\ioncap.exe";
        procIonCap.StartInfo.WindowStyle =
                System.Diagnostics.ProcessWindowStyle.Normal;
        procIonCap.StartInfo.ErrorDialog = true;

Quote:
}

protected void procIonCap_Exited (object sender, System.EventArgs e)
{
        Debug.WriteLine("IONCAP returned");

Quote:
}

public void ExecuteIONCAP()
{
        procIonCap.WatchForExit = true;
        procIonCap.Start();
        Debug.WriteLine("Leaving ExecuteIONCAP...");

Quote:
}

Anyone see anything wrong with my use of the Process object?  Is there
something special I need to do with 16 bit app calls?

Tom Childers
President, Tom Childers, Inc.

http://www.*-*-*.com/



Tue, 11 Nov 2003 07:24:32 GMT  
 Executing Old 16 Bit DOS Apps from C# via System.Diagnostics.Process
Tom,

ShellExecuteEx (which is what Process.Start calls internally) knows
nothing about piping characters (< > |), only the command interpreter
does. So you could try doing it like this instead:

procIonCap.StartInfo.FileName =
Environment.GetEnvironmentVariable("COMSPEC");

In beta 2, the ProcessStartInfo will allow you to pipe from a stream
to stdin of the launched process.

Mattias

====================================

http://www.msjogren.net/dotnet/

CodeHound - The Software Developer's Search Engine
http://www.codehound.com



Tue, 11 Nov 2003 10:30:44 GMT  
 Executing Old 16 Bit DOS Apps from C# via System.Diagnostics.Process
Mattias,

Thank you.  I tried it but it still wouldn't run, but the command line
you gave helped me resolve the problem.  The problem was that the
directory was not being changed by the command. I discovered this by
substituting the /C switch in your command line with /K to make the
DOS window stay open and found that it was not finding the file
because cmd.exe was being executed from the winnt\system32 folder.

It works now the way I called it originally, however I did not mention
that I was running it on Win 2k pro, which apparently understands
piping symbols.  I believe it is Win 95 and win 98 that exhibit the
behavior you described.

Thanks for the help.  If not for yoyr help I would probably still be
floundering..

Tom

Quote:

>Tom,

>ShellExecuteEx (which is what Process.Start calls internally) knows
>nothing about piping characters (< > |), only the command interpreter
>does. So you could try doing it like this instead:

>procIonCap.StartInfo.FileName =
>Environment.GetEnvironmentVariable("COMSPEC");
>procIonCap.StartInfo.Arguments =

>In beta 2, the ProcessStartInfo will allow you to pipe from a stream
>to stdin of the launched process.

>Mattias

>====================================

>http://www.msjogren.net/dotnet/

>CodeHound - The Software Developer's Search Engine
>http://www.codehound.com

Tom Childers
President, Tom Childers, Inc.

http://www.arltex.com


Wed, 12 Nov 2003 18:37:07 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Process class problems with 16 bit DOS command.

2. reading old data, 16 bit application vs 32 bit application

3. How do I create a 16 bit DOS app with VC++ Ver 4

4. Calling a 16-bit system DLL from my 32-bit exe

5. 32 bit app connects to 16 bit dsn

6. Is there any way to use 16-bit DLL in a 32-bit app?(VC++ 6.0)

7. CBT Hook from 32 bit on a 16 bit app

8. Is there any way to use 16-bit DLL in a 32-bit app?(VC++ 6.0)

9. Thunking/32 bit child window in 16 bit parent app

10. CBT Hook from 32 bit on a 16 bit app

11. 16 bit app calling 32 bit DLL

12. Q: 16-bit DLL call from 32-bit VC++ App

 

 
Powered by phpBB® Forum Software