Process p =
new Process();
p.StartInfo.FileName =
"cmd.exe";
p.StartInfo.UseShellExecute =
false;
p.StartInfo.RedirectStandardInput =
true;
p.StartInfo.RedirectStandardOutput =
true;
p.StartInfo.RedirectStandardError =
true;
p.StartInfo.CreateNoWindow =
true;
string strpath = MapPath(
@"~\App\AcmeCADConverter");
//放在站点目录不用设置过多的权限
string stroutpath = MapPath(
@"~\Out");
//输出目录也放在站点下面
string strinpath = MapPath(
@"~\Infiles\");
//文件也放在站点目录下面
string commandText = strpath +
@"\AcmeCADConverter /r /e /w 1280 /h 800 /f 2 /d " + stroutpath +
" " + strinpath +
"test.dwg";
//要执行的cmd命令
p.Start();
p.StandardInput.WriteLine(commandText);
p.StandardInput.WriteLine("exit");
p.WaitForExit();
p.Close();
Response.Write("执行完成");
View Code
为了执行方便,我们把所有文件都放在站点目录下,这样不需要设置过多的权限
http://files.cnblogs.com/techMichaelLee/WebTest.rar
转载于:https://www.cnblogs.com/LeeYZ/p/3404715.html