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

  • 相关阅读:
    MySQL之字符集
    PHP7.0-PHP7.3新特性与变更
    MySQL之开发规范
    php框架之thinkphp
    MySQL之日期时间类型
    php扩展之Yar
    XAMPP支持多PHP版本
    MySQL之执行流程
    RabbitMQ之php-amqplib使用
    (转)YAML最最基础语法
  • 原文地址:https://www.cnblogs.com/LeeYZ/p/3404715.html
Copyright © 2011-2022 走看看