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

Y

Yehuda Vernik

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();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top