[Overview][Classes][Procedures and functions][Index] Reference for unit 'UTF8Process' (#lazutils)

RunCmdFromPath

Executes a command found in the current PATH environment.

Declaration

Source position: utf8process.pp line 54

procedure RunCmdFromPath(

  const ProgramFilename: string;

  const CmdLineParameters: string

);

Arguments

ProgramFilename

  

Path and name for the program executed.

CmdLineParameters

  

Command line parameters for the program.

Description

RunCmdFromPath is used to execute a command which can be found in the current PATH environment. For example, the following locates and executes the /bin/ls -l /home command:

RunCmdFromPath('ls', '-l /home');

An exception is raised if the program file cannot be located, or cannot be executed.

RunCmdFromPath creates and configures a TProcessUTF8 instance which is used to execute the program file. ProgramFilename contains the qualified executable file name for the process. If the argument contains a Space (' '), it is surrounded by Quotation Mark (") characters before it is assigned to the class instance. CmdLineParameters contains optional parameters values for the executable file. It is assumed that parameter values with embedded spaces are already quoted when passed to the routine. CmdLineParameters is included in the class instance when the value is not an empty string ('').

RunCmdFromPath calls the Execute method in the TProcessUTF8 instance to execute the specified program file name with the specified parameter values.

Errors

EFOpenError
Raised with the message in lrsProgramFileNotFound or lrsCanNotExecute.

See also

TProcess.Execute

TProcess.CommandLine

TProcess.Executable

TProcess.Parameters

TProcess.Environment


Version 3.2 Generated 2024-02-25 Home