首页 > 解决方案 > 执行批处理文件存在重复文件名,或找不到文件

问题描述

通过C#执行一个复杂的批处理文件,设置会话变量示例

SET TEST = rainbow

成名

A duplicate file name exists, or the file cannot be found.

我用了

string args = string.Format("/k \"cd /d {0} && {1}\"", s.Path, s.Filename + " " + userChoice);
    RunBatch("cmd.exe", args, s.Path);
.
.
        ProcessStartInfo startInfo = new ProcessStartInfo()
        {
            UseShellExecute = false,
            WorkingDirectory = workingDir,
            FileName = cmd,
            Arguments = cmdArgs
        };

        Process.Start(startInfo);

在简单的批处理文件上尝试时。随着复杂的出现上面提到的错误。

--

我还尝试用 C#编写,这是一个的批处理文件,第一行有

setlocal enableextensions disabledelayedexpansion

,然后调用需要的,并通过C#执行这个批处理,错误又是一样的......

任何提示?

标签: c#batch-filecmd

解决方案


推荐阅读