Skip to content

Replacement for System.Diagnostics.Process

License

Notifications You must be signed in to change notification settings

Headkillah/RunProcess

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RunProcess

A process host for Windows (Vista and later) that is more reliable and flexible than System.Diagnostics.Process

Allows run-time reading from std error and output, and writing to std input.

Usage

Like this

using (var proc = new ProcessHost("my.exe", @"C:\temp\")) {
    proc.Start();
}

Or,

using (var proc = new ProcessHost(msBuildExe, projectDir)) {
    proc.Start(projectFile + " /t:Publish");
        
    int resultCode;
    if (!proc.WaitForExit(TimeSpan.FromMinutes(1), out resultCode))
    {
        proc.Kill();
        throw new Exception("Publish killed -- took too long");
    }

    File.AppendAllText(logFile, proc.StdOut.ReadAllText(Encoding.UTF8));
    File.AppendAllText(logFile, proc.StdErr.ReadAllText(Encoding.UTF8));

    if (resultCode != 0)
    {
        throw new Exception("Publish failure: see \"" + logFile + "\" for details");
    }
}

About

Replacement for System.Diagnostics.Process

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%