一台装有xp,iis,vs2008的机子,在vs2008中,用
p.StartInfo.FileName = @"cmd.exe";
p.Start();
能打开cmd.exe程序,但在iis中,通过网址访问,例如: http://localhost/afg/ 访问时,不能打开cmd.exe程序,估计是权限的问题,这权限到底该怎样设置? 还有,如果想向这个打开的cmd.exe程序中写入命令,例如: dir d: , 网上介绍用
p.StandardInput.WriteLine("dir d:");
但试过,是不行的.
p.StartInfo.Arguments = @"/c dir d:"; 也是不行的.
到底怎样才能向打开的cmd.exe程序传送命令?
p.StartInfo.FileName = @"cmd.exe";
p.Start();
能打开cmd.exe程序,但在iis中,通过网址访问,例如: http://localhost/afg/ 访问时,不能打开cmd.exe程序,估计是权限的问题,这权限到底该怎样设置? 还有,如果想向这个打开的cmd.exe程序中写入命令,例如: dir d: , 网上介绍用
p.StandardInput.WriteLine("dir d:");
但试过,是不行的.
p.StartInfo.Arguments = @"/c dir d:"; 也是不行的.
到底怎样才能向打开的cmd.exe程序传送命令?
http://mxdev.blogspot.com/2008/09/asp-net-run-application-exe-from-aspnet.html
{
string strFilePath="F:\\read.bat";
ProcessStartInfo psi=new ProcessStartInfo("cmd.exe");
psi.UseShellExecute=false;
psi.RedirectStandardOutput=true;
psi.RedirectStandardInput=true;
psi.RedirectStandardError=true;
psi.WorkingDirectory="F:\\"; Process proc=Process.Start(psi); StreamReader sr=File.OpenText(strFilePath);
StreamReader sOut=proc.StandardOutput;
StreamWriter sw=proc.StandardInput; while(sr.Peek()!=-1)
{
sw.WriteLine(sr.ReadLine());
}
}bat中的内容就是要在cmd中执行的命令,例如dir
但问题是cmd的窗口不显示出来.有什么办法让他显示出来?