zoukankan      html  css  js  c++  java
  • asp.net执行cmd命令(包括第三方应用的命令行)

    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(@"~AppAcmeCADConverter");//放在站点目录不用设置过多的权限
    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

    为了执行方便,我们把所有文件都放在站点目录下,这样不需要设置过多的权限

    https://files.cnblogs.com/techMichaelLee/WebTest.rar

  • 相关阅读:
    LeetCode
    LeetCode
    LeetCode
    LeetCode
    剑指offer-栈的压入、弹出序列
    剑指offer-包含min函数的栈
    图-Dijkster最短路径
    剑指offer-顺时针打印矩阵
    二叉树的镜像
    剑指offer-树的子结构
  • 原文地址:https://www.cnblogs.com/LeeYZ/p/3404715.html
Copyright © 2011-2022 走看看