DelphiDabbler Wiki

Console Application Runner ClassesExecute method

Project: Console Application Runner Classes

Unit: PJConsoleApp

Classes: TPJCustomConsoleApp, TPJConsoleApp

Introduced: v1.0

function Execute(const CmdLine, CurrentDir: string = ''): Boolean; overload;

Introduced: v2.0

function Execute: Boolean; overload;


Executes the command line application.

The first, original version of the method has the command line and (optionally) the current directory passed as parameters:

  • CmdLine: Command line to be executed. This should include the name of the application (with path if necessary) along with any required parameters. Paths and parameters containing spaces should be enclosed in double quotes.
  • CurrentDir: The directory that the application is to treat as its current directory.

The second, parameterless, version of the method was introduced in version 2. It executes the command line specified by the CommandLine property with the current directory specified by the CurrentDir property.

Execute returns True if the application was executed successfully and False if the application failed to run. When False is returned, the ErrorCode property will contain a non-zero error code.


If the current directory (however specified) is the empty string then the executed application's current directory will be that of its parent process.

If the CmdLine parameter is specified then the CommandLine property will be updated to the same value.

Similarly the CurrentDir property receives the value of any CurrentDir parameter.

Page last modified on May 08, 2011, at 12:47 PM