Skip to content

kenny-evitt/ExecuteCommandLineProgram

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Overview of the ExecuteCommandLineProgram Library

ExecuteCommandLineProgram is a .NET (4) class library for executing command line programs.

The code was copied and slightly modified from this answer to the Stack Overflow question How to capture Shell command output in C#?.

This answer to the Stack Overflow question run interactive command line exe using c# provided the necessary resource info for me to add support for supporting standard-input input.

Example usage:

CommandLineProgramProcessResult result =
    CommandLineProgramProcess.RunProgram(
        @"C:\Program Files (x86)\SomeFolder\SomeProgram.exe",             // Path of executable program
        @"C:\Program Files (x86)\SomeFolder\",                            // Path of working directory
        String.Format(@"""{0}""", filePathThatNeedsToBeQuotedArgument),   // Command line arguments
        10 * 60 * 1000);                                                  // Timeout, in milliseconds
        
string standardError = result.StandardError;
string standardOutput = result.StandardOutput;
int exitCode = result.ExitCode;

Example usage for supplying input via standard input:

CommandLineProgramProcessResult result =
    CommandLineProgramProcess.RunProgram(
        @"C:\Program Files (x86)\SomeFolder\SomeProgram.exe",             // Path of executable program
        @"C:\Program Files (x86)\SomeFolder\",                            // Path of working directory
        String.Format(@"""{0}""", filePathThatNeedsToBeQuotedArgument),   // Command line arguments
        10 * 60 * 1000,                                                   // Timeout, in milliseconds
        inputData);                                                       // Standard-input input, as a string
        
string standardError = result.StandardError;
string standardOutput = result.StandardOutput;
int exitCode = result.ExitCode;

About

.NET (4) class library for executing a command line program.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages