unity C#执行bat文件

unity的文件

普通的,调用bat目录即可

csharp 复制代码
[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文件 不能直接使用全目录

csharp 复制代码
[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);
}
相关推荐
星夜泊客25 分钟前
C# : 引用类型都存在堆上吗
unity·c#
chiwei_hua32 分钟前
如何在 Blazor Web 前端中使用 C# 进行数据交互?
前端·c#·交互
点量云实时渲染-小芹39 分钟前
Unity模型数字孪生虚拟仿真webgl推流卡实时云渲染推流
unity·webgl·数字孪生·实时云渲染·虚拟仿真·云推流
wenroudelang88884 小时前
Visual Studio的C#实例--2个窗体之间跳转
ide·c#·visual studio
荔枝吻4 小时前
【AI总结】C#与.NET:一段跨越20年的命名纠葛与共生传奇
开发语言·c#·.net
波波0075 小时前
每日一题:请解释 .NET中的内存模型是什么
开发语言·c#·.net
眼眸流转6 小时前
LeetCode热题100(七)
算法·leetcode·c#
mxwin6 小时前
Unity Shader 齐次坐标与透视除法理解 SV_POSITION 的 w 分量
unity·游戏引擎·shader
格林威7 小时前
工业相机图像采集处理:从 RAW 数据到 AI 可读图像,附海康相机 C++实战代码
开发语言·c++·人工智能·数码相机·计算机视觉·c#·工业相机
需要点灵感7 小时前
# 从身份证读卡到钉钉同步:C# WinForms企业级应用开发实战
开发语言·c#·钉钉