unity C#执行bat文件

unity的文件

普通的,调用bat目录即可

[MenuItem("Tools/GenerateBat普通的", priority = 101)]
public static void GenerateBat普通的()
{
    ProcessStartInfo startInfo = new ProcessStartInfo
    {
        FileName = "cmd.exe",
        Arguments = "/C G:/gitHub/HYFClient/Excel_luban/normal.bat",
        UseShellExecute = false,
        RedirectStandardOutput = true,
        CreateNoWindow = true
    };
    Process process = new Process { StartInfo = startInfo };
    process.Start();
    string output = process.StandardOutput.ReadToEnd();
    process.WaitForExit();
    AssetDatabase.Refresh();
    Debug.LogFormat("普通的,结果会有--,{0}",output);
}  

诡异的,这bat文件,非得cd到目录里,再调用下bat文件 不能直接使用全目录

[MenuItem("Tools/GenerateBat诡异的", priority = 102)]
public static void GenerateBat诡异的()
{
    var cdPath = Application.dataPath.Replace("Assets", "Excel_luban");
    ProcessStartInfo startInfo = new ProcessStartInfo
    {
        FileName = "cmd.exe",
        Arguments = $"/C cd /D {cdPath} && gen.bat", //非得cd到某目录,再调用下bat文件      不能直接使用全目录
        UseShellExecute = false,
        RedirectStandardOutput = true,
        CreateNoWindow = true
    };
    Process process = new Process { StartInfo = startInfo };
    process.Start();
    string output = process.StandardOutput.ReadToEnd();
    process.WaitForExit();    
    AssetDatabase.Refresh();
    Debug.LogFormat("luban执行成功,数据lubanBytes,代码lubanCodes--,{0}",output);
}

相关推荐

  1. unity C#执行bat文件

    2024-07-19 04:48:06       19 阅读
  2. 编写bat脚本执行msyql建库sql

    2024-07-19 04:48:06       49 阅读
  3. BAM文件数据结构详解

    2024-07-19 04:48:06       54 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-19 04:48:06       67 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-19 04:48:06       71 阅读
  3. 在Django里面运行非项目文件

    2024-07-19 04:48:06       58 阅读
  4. Python语言-面向对象

    2024-07-19 04:48:06       69 阅读

热门阅读

  1. C语言 分割链表

    2024-07-19 04:48:06       20 阅读
  2. 如何使用Python实现一个简单的Web服务器

    2024-07-19 04:48:06       17 阅读
  3. 微服务重启优化kafka+EurekaNotificationServerListUpdater

    2024-07-19 04:48:06       21 阅读
  4. 降低芯片流片风险的几种方法

    2024-07-19 04:48:06       23 阅读
  5. MySQL 架构中的三层服务是什么?

    2024-07-19 04:48:06       19 阅读
  6. C语言——函数指针

    2024-07-19 04:48:06       18 阅读
  7. 玩转springboot之springboot启动原理

    2024-07-19 04:48:06       21 阅读
  8. Python(字典)

    2024-07-19 04:48:06       22 阅读
  9. 部署和运维

    2024-07-19 04:48:06       15 阅读
  10. junit mockito Base基类

    2024-07-19 04:48:06       20 阅读
  11. 代码随想录-DAY⑩-二叉树——leetcode 144 | 94 | 145

    2024-07-19 04:48:06       21 阅读