Cannot execute command line program in cmd.exe under aspx form

From: Yehuda Vernik (yvernik_at_plusfunds.com)
Date: 09/15/04


Date: Wed, 15 Sep 2004 15:41:21 -0400

Hi All.

I am trying to run an exe application under aspx page using
System.Diagnostics.ProcessStartInfo and System.Diagnostics.Process.

The process gets started but "freezes" without any error messages. The
process output stream gives me something like this:

C:\Inetpub\wwwroot\Portal\script>MyProgram.exe MyArguments

C:\Inetpub\wwwroot\Portal\script>

--------------------------
instead of:

C:\Inetpub\wwwroot\Portal\script>MyProgram.exe MyArguments
MyProgramExecutionOutput
MyProgramExecutionOutput
MyProgramExecutionOutput
C:\Inetpub\wwwroot\Portal\script>

I made sure that the folder C:\Inetpub\wwwroot\Portal\script is configured
under IIS to run executables.
I also made sure that .NET Configuration 1.1 Machine and User have full
trust.

What else you suggest I need to check?

Is there any site that explans all the security settings that I need to go
over in order to run CMD.EXE?

Thanks a lot,

Yehuda

My code:
-------------------------------------------
System.Diagnostics.ProcessStartInfo psi = new
System.Diagnostics.ProcessStartInfo("cmd.exe");

psi.UseShellExecute = false;

psi.RedirectStandardOutput = true;

psi.RedirectStandardInput = true;

psi.RedirectStandardError = true;

psi.WorkingDirectory = @"c:\Inetpub\wwwroot\Portal\script";

System.Diagnostics.Process proc = System.Diagnostics.Process.Start(psi);

System.IO.StreamWriter streamIn = proc.StandardInput;

System.IO.StreamReader streamOut = proc.StandardOutput;

String strCommand =

@"gpg.exe -d --batch --passphrase-fd 0 -r funds -o
C:\Inetpub\wwwroot\Portal\script\files_xml\2004091010.XML
C:\Inetpub\wwwroot\Portal\script\2004091010.XML.asc < funds.txt";

streamIn.WriteLine(strCommand);

proc.WaitForExit(2000);

streamIn.WriteLine("EXIT");

proc.Close();

string results = streamOut.ReadToEnd().Trim();

streamIn.Close();

streamOut.Close();

--------------

I have copies of cmd.exe file in my BIN folder and my
c:\Inetpub\wwwroot\Portal\script folder.



Relevant Pages

  • RE: Asynchronous Web Service Method Failure
    ... When a session begins, I create a folder for that session in a virtual ... When the user requests a report, sometimes a stream is opened to load some ... the URL of the file is returned by the web service method. ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • NTFS: minor flaws in handling of streams and tunneling
    ... In NTFS every file can have streams. ... If you add this stream by entering a comment in the properties of the ... NTFS Tunneling preserves the date values of files when you replace ... delete file Z from folder F ...
    (microsoft.public.win32.programmer.kernel)
  • Re: minor flaws in handling of streams and tunneling
    ... If you add this stream by entering a comment in the properties of the ... NTFS Tunneling preserves the date values of files when you replace ... In addition you can disable Tunneling by setting ... delete file Z from folder F ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Include image from local directory to webform?
    ... your ProcessRequest will read the image file from the folder as ... requested and stream it back to the client. ... But I'm interest is there a way to avoid creating virtual directory. ... allication to read from local dir, and sream into HTML response. ...
    (microsoft.public.dotnet.framework.aspnet)