[Lazarus] Launching External Tool Cmd.exe in Windows

shoKwave shokwave at gmx.net
Fri Sep 23 15:49:25 CEST 2016


Am 22.09.2016 um 23:13 schrieb Lars:
>
> To clarify I meant the external tools in the IDE that allow you to launch
> a tool from the IDE tools menu...
> i.e. not actual lazarus coding, but a tool to launch from the IDE. Most
> text editors have this feature, lazarus has really good access to lots of
> macros that fill in values.
I'm sorry, I totally misread your mail.

As a workaround (Mathias already fixed it in trunk) you could use a 
simple program to start the program you actually want to run. I attached 
an example (runner.lpi). It just starts the program given in the 1st 
parameter with all following parameters.

The picture shows how I used it to run the time command inside the cmd.exe.

Hope this helps you.

Ingo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lazarus.PNG
Type: image/png
Size: 9185 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20160923/89b45706/attachment-0001.png>
-------------- next part --------------
program runner;

uses SysUtils, Process;

var AProc: TProcess;
    i: Integer;

begin
  //Any Parameters at all?
  if ParamCount > 0 then
  begin
    //Create the Process
    AProc:= TProcess.Create(NIL);
    //First parameter is the program to run
    AProc.Executable := ParamStr(1);
    //Add Parameters
    if ParamCount > 1 then
    begin
      for i := 2 to ParamCount do
      begin
        AProc.Parameters.Add(ParamStr(i));
      end;
    end;
    //Run and free the Process
    try
      AProc.Execute;
    finally
      AProc.Free;
    end;
  end;
end.



More information about the Lazarus mailing list