Unable to redirect ONLY the standard input of process "cmd.exe" (or batch file) from windows form application - by daat99

Status : 

  Won't Fix<br /><br />
		Due to several factors the product team decided to focus its efforts on other items.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 609801 Comments
Status Closed Workarounds
Type Bug Repros 4
Opened 10/3/2010 6:15:37 AM
Access Restriction Public


More info can be found on these posts:


Basically when I attempt to redirect the standard input of a console application from windows form the console application crashes immediately.
When I use the exact same code from a console application everything works fine (this is what leads me to believe it might be a bug).

Here's the shortest code you need to reproduce the problem:

Process myProcess = new Process();
myProcess.StartInfo.FileName = @"cmd.exe";
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.RedirectStandardInput = true;

Please note the following:

1. When I change "cmd.exe" to "sort.exe" it works find on both console and windows form applications.

2. When compiling to windows application for 64 bit platform (or AnyCPU) the "myProcess.MainModule" throws an exception: {"Only part of a ReadProcessMemory or WriteProcessMemory request was completed"}

3. When compiling to windows application for 32 bit platform the "myProcess.MainModule" throws an exception: {"A 32 bit processes cannot access modules of a 64 bit process."}

4. When I redirect both the standard input and the standard output everything works fine.

I scanned the net and I was able to find only a few posts regarding this issue in multiple sites.

The posts I found didn't provide a solution and used the programming languages c# and vb.net.

That basically leads me to think the problem is in .NET itself.

I'm using Windows 7 x64 Ultimate and Visual Studio 2010 Ultimate with .NET 4.

I'm yet to find any workaround for redirecting only the input of a console application from a windows form application.

If you know of any workaround that allows me to do that please let me know.

Thanks in advance,

Sign in to post a comment.
Posted by Adam Cabler on 3/2/2011 at 9:55 PM
I have this problem also. I'm trying to capture only stdout and stderr. The process exits immediately with:

+        base    {"Only part of a ReadProcessMemory or WriteProcessMemory request was completed"}    System.Runtime.InteropServices.ExternalException {System.ComponentModel.Win32Exception}

The workaround is to redirect all 3 streams (stdin for me) to get this to work.
Posted by Microsoft on 11/12/2010 at 4:53 PM
Thank you for reporting this issue. Customer feedback is a critical part of a successful, impactful software product. Unfortunately another part is the reality of schedules and the need to prioritize investments according to the objectives of the product. We have evaluated the issue that you have reported and at this point in the product's lifecycle, it does not meet the criteria to be addressed. This evaluation is carefully done and considers many aspects including the cost of the fix, implications of the change, and the number of reported instances of the issue.

Many customers have found it useful to discuss issues like this in the forums (http://www.microsoft.com/communities/forums/default.mspx) where Microsoft and other members of the community can recommend ways of achieving the behavior you are interested in.

Thank you,
The Windows Forms Product Team
Posted by Microsoft on 10/3/2010 at 6:21 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)