Hello, I have a problem in executing command line
from a web application. When clicking button "submit",
I can see the command process in "task manager", however,
the process seems hang-up and no any output results.
Why the same code can run in windows application, but
failed in web application?
Can anybody help me?
Thank you.
here is my code
-------------------------------------------------
private void BtnSubmit_Click(object sender, System.EventArgs e)
{
int ret;
ret = ExecuteExternalCommand(mycmd.bat, 10000);
}
public int ExecuteExternalCommand(string cmd_string, int waiting_time)
{
System.Diagnostics.ProcessStartInfo psi =
new System.Diagnostics.ProcessStartInfo(@cmd_string);
psi.RedirectStandardOutput = true;
psi.CreateNoWindow = false;
psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
psi.UseShellExecute = false;
System.Diagnostics.Process listFiles;
listFiles = System.Diagnostics.Process.Start(psi);
System.IO.StreamReader AppOutput=listFiles.StandardOutput;
listFiles.WaitForExit(waiting_time);
if(listFiles.HasExited)
{
return 0;
}
else
{
listFiles.Close();
}
return 1;
}
from a web application. When clicking button "submit",
I can see the command process in "task manager", however,
the process seems hang-up and no any output results.
Why the same code can run in windows application, but
failed in web application?
Can anybody help me?
Thank you.
here is my code
-------------------------------------------------
private void BtnSubmit_Click(object sender, System.EventArgs e)
{
int ret;
ret = ExecuteExternalCommand(mycmd.bat, 10000);
}
public int ExecuteExternalCommand(string cmd_string, int waiting_time)
{
System.Diagnostics.ProcessStartInfo psi =
new System.Diagnostics.ProcessStartInfo(@cmd_string);
psi.RedirectStandardOutput = true;
psi.CreateNoWindow = false;
psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
psi.UseShellExecute = false;
System.Diagnostics.Process listFiles;
listFiles = System.Diagnostics.Process.Start(psi);
System.IO.StreamReader AppOutput=listFiles.StandardOutput;
listFiles.WaitForExit(waiting_time);
if(listFiles.HasExited)
{
return 0;
}
else
{
listFiles.Close();
}
return 1;
}