示例#1
0
    public async Task Run()
    {
        var process = new WinProcess("robocopy");

        if (outputToConsole)
        {
            process.WriteOutputToConsole();
        }
        process
        .UseArgumentNameDelimiter("")
        .AddArgument(new Quoted(source))
        .AddArgument(new Quoted(target))
        .AddArgument(pattern)
        .UseArgumentNameDelimiter("/")
        .UseArgumentValueDelimiter(":")
        .SetWorkingDirectory(workingDirectory);
        foreach (var arg in options)
        {
            process.AddArgument(arg);
        }
        if (attributesToAdd.Any())
        {
            process.AddArgument("a+", string.Join("", attributesToAdd));
        }
        var result = await process.Run();

        if (result.ExitCode >= 8)
        {
            throw new Exception($"robocopy failed with exit code {result.ExitCode}");
        }
    }
示例#2
0
    private WinProcess createProcess()
    {
        var process = new WinProcess("psexec");

        if (outputToConsole)
        {
            process.WriteOutputToConsole();
        }
        process.UseArgumentNameDelimiter("");
        process.AddArgument(server);
        process.AddArgument(remoteProcess.CommandText());
        return(process);
    }
示例#3
0
    private WinProcess createProcess()
    {
        var process = new WinProcess("cmd");

        process.SetWorkingDirectory(workingDirectory);
        if (outputToConsole)
        {
            process.WriteOutputToConsole();
        }
        process.UseArgumentNameDelimiter("/");
        process.AddArgument("C");
        process.UseArgumentNameDelimiter("");
        process.AddArgument(otherProcess.CommandText());
        return(process);
    }
示例#4
0
    private WinProcess createWinProcess()
    {
        var process = new WinProcess(fileName);

        if (outputToConsole)
        {
            process.WriteOutputToConsole();
        }
        process.UseArgumentNameDelimiter("--");
        process.UseArgumentValueDelimiter(" ");
        process.AddArgument("environment", environment.Value);
        process.SetWorkingDirectory(workingDirectory);
        var dict = config.ToDictionary();

        foreach (var key in dict.Keys)
        {
            process.AddArgument(key, new Quoted(dict[key]));
        }
        return(process);
    }