Skip to main content

Script Class

Package: GHIElectronics.Endpoint.Core
Namespace: GHIElectronics.Endpoint.Core

Runs an external program and collects what it prints. Used internally by the Endpoint libraries where a direct API is not yet available; prefer the direct API where one exists.

public class Script

Nested Types​

TypeKindSummary
Script.OutputDataReceivedEventHandlerDelegateSignature for the Script.OutputDataReceived event.

Constructors​

Script(string filename, string workingdir, string arguments)​

public Script(string filename, string workingdir, string arguments)

Prepares to run filename with the given arguments and working directory.

ParameterTypeDescription
filenamestringPath to the program, or a name that PATH resolves.
workingdirstringWorking directory for the program; empty for the current one.
argumentsstringCommand-line arguments as a single string, split by the shell convention.

Properties​

Error​

public string Error { get; }

Everything the program has printed to standard error so far, newline-separated.

Returns string

ExitCode​

public int ExitCode { get; }

The program's exit code; -1 if it could not be started

Returns int

IsBusy​

public bool IsBusy { get; }

True while the program is running (between Script.Start and the program's exit).

Returns bool

Output​

public string Output { get; }

Everything the program has printed to standard output so far, newline-separated.

Returns string

Methods​

Start(bool waitforexit)​

public void Start(bool waitforexit)

Starts the program and, unless told otherwise, waits until it ends

Stop()​

public void Stop()

Ends the program (and what it started)

Events​

OutputDataReceived​

public event OutputDataReceivedEventHandler OutputDataReceived

Each line the program prints, as it prints it