Welcome to the new DelphiDabbler Code Library Documentation.

This is a new site that's currently running on alpha code. There are going to be bugs. If you discover any, please report them on the site's issues page (GitHub account required). Thanks.

Warning: Many URLs are going to change. Refer to the README file to discover which library project's documentation has been completed.

TPJConsoleApp class

Project: Console Application Runner Classes

Unit: PJConsoleApp

Applies to: ~>3.0


This class is designed to be used to control the execution of child console application processes. The class provides facilities to redirect the console process’ standard input, output and error handles. The application’s execution can be given a time-out and can be time sliced to allow progress to be reported and redirected output to be handled while the console application continues to execute. Security levels and environment blocks can be customised. Errant processes can be terminated. Finally, the program’s exit code is made available.

TPJConsoleApp descends from TPJCustomConsoleApp. The only differences are that TPJCustomConsoleApp declares all properties and events as protected whereas TPJConsoleApp makes them all public.


Method Description
Execute Executes the console application.
Terminate Attempts to terminate the console application process.


Property Description
CommandLine Command line used to execute a console application.
ConsoleColors Foreground and background colours used in console window.
ConsoleTitle Title to be displayed in any new console window.
CurrentDir Application’s current directory.
ElapsedTime Approximate time in milliseconds since the console application began executing.
Environment Pointer to the environment block used by the console application.
ErrorCode Provides information about any error that occurred while attempting to run a console application.
ErrorMessage Error message corresponding to any non-zero value of ErrorCode.
ExitCode Exit code returned by the console application on completion.
KillTimedOutProcess Indicates whether timed-out processes should be terminated or left running.
MaxExecTime Maximum permitted execution time of the console application.
Priority Priority with which the console application is started.
ProcessAttrs Specifies security and inheritance attributes for the console application process.
ProcessInfo Provides process information for the executing console application.
ScreenBufferSize Size of console’s screen buffer.
StdErr The console application’s standard error handle.
StdIn The console application’s standard input handle.
StdOut The console application’s standard output handle.
ThreadAttrs Security and inheritance attributes for the console application’s primary thread.
TimeSlice Length of each time slice for a timed sliced console application.
TimeToLive Amount of time a console application has left to run before timing out.
UnicodeEnvironment [~>3.1] Determines whether environment block referenced by Environment is in Unicode or ANSI.
UseNewConsole Determines if a console application opens a new console window when run.
Visible Determines whether the console application is to be displayed.
WindowPosition Position of console window on screen.
WindowSize Size of console window.


Event Description
OnComplete Triggered when an application completes or times out.
OnStart Triggered after a console application process is created and just before it starts executing.
OnWork Triggered when the executing application yields control to this class. Permits necessary work to be completed.

See Also