[Lazarus] Launching External Tool Cmd.exe in Windows

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

[Lazarus] Launching External Tool Cmd.exe in Windows

Lars
Hi, Lazarus has the nice feature of being able to launch an external tool.

I'm trying to launch a console app...

So I put C:\Windows\System32\cmd.exe in the program file name for the
external tool. This does nothing and gives no error message. Also add the
parameter /k and it still does nothing.

Any idea how to get lazarus to launch a simple cmd.exe instance as an
external tool? Should this be filed as a bug if it doesn't work?

Other things I will try... COMSPEC... but still cmd.exe should work, no?


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Launching External Tool Cmd.exe in Windows

shoKwave
Hi,

I simply tried putting a TProcess and a TButton on a form and used
following code

procedure TForm1.Button1Click(Sender: TObject);
begin
   Process1.ApplicationName:='c:\windows\system32\cmd.exe';
   Process1.Execute;
end;

Works for me on a Win10 32bit machine with FPC 3.0.0 and Lazarus 1.6.

Ingo

Am 22.09.2016 um 08:14 schrieb Lars:

> Hi, Lazarus has the nice feature of being able to launch an external tool.
>
> I'm trying to launch a console app...
>
> So I put C:\Windows\System32\cmd.exe in the program file name for the
> external tool. This does nothing and gives no error message. Also add the
> parameter /k and it still does nothing.
>
> Any idea how to get lazarus to launch a simple cmd.exe instance as an
> external tool? Should this be filed as a bug if it doesn't work?
>
> Other things I will try... COMSPEC... but still cmd.exe should work, no?
>
>

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Launching External Tool Cmd.exe in Windows

Mattias Gaertner
In reply to this post by Lars
On Thu, 22 Sep 2016 00:14:17 -0600
"Lars" <[hidden email]> wrote:

> Hi, Lazarus has the nice feature of being able to launch an external tool.
>
> I'm trying to launch a console app...
>
> So I put C:\Windows\System32\cmd.exe in the program file name for the
> external tool. This does nothing and gives no error message. Also add the
> parameter /k and it still does nothing.
>
> Any idea how to get lazarus to launch a simple cmd.exe instance as an
> external tool? Should this be filed as a bug if it doesn't work?
>
> Other things I will try... COMSPEC... but still cmd.exe should work, no?

I added two options "Show console" and "Hide window". Enable Show
console and disable Hide window and cmd.exe will be shown in a console
window.

Mattias
--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Launching External Tool Cmd.exe in Windows

Lars
In reply to this post by shoKwave
On Thu, September 22, 2016 2:38 am, shoKwave wrote:

> Hi,
>
>
> I simply tried putting a TProcess and a TButton on a form and used
> following code
>
> procedure TForm1.Button1Click(Sender: TObject); begin
> Process1.ApplicationName:='c:\windows\system32\cmd.exe';
> Process1.Execute;
> end;
>
> Works for me on a Win10 32bit machine with FPC 3.0.0 and Lazarus 1.6.
>


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.

For some reason cmd.exe /k doesn't launch the command line from lazarus
external tools in the menu. /k option keeps the command line window open
--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Launching External Tool Cmd.exe in Windows

Lars
In reply to this post by Mattias Gaertner
On Thu, September 22, 2016 3:08 am, Mattias Gaertner wrote:
>
> I added two options "Show console" and "Hide window". Enable Show
> console and disable Hide window and cmd.exe will be shown in a console
> window.
>
> Mattias


Oh, when did you add this, long ago or just recent... which release... or
is it only on the latest github/svn. Thanks, I did not see this option
--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Launching External Tool Cmd.exe in Windows

Mattias Gaertner
On Thu, 22 Sep 2016 15:14:21 -0600
"Lars" <[hidden email]> wrote:

> On Thu, September 22, 2016 3:08 am, Mattias Gaertner wrote:
> >
> > I added two options "Show console" and "Hide window". Enable Show
> > console and disable Hide window and cmd.exe will be shown in a console
> > window.
> >
> > Mattias  
>
>
> Oh, when did you add this, long ago or just recent... which release... or
> is it only on the latest github/svn. Thanks, I did not see this option

Just recently, as in today.

Mattias
--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Launching External Tool Cmd.exe in Windows

Lars
On Thu, September 22, 2016 3:45 pm, Mattias Gaertner wrote:
>> Oh, when did you add this, long ago or just recent... which release...
>> or is it only on the latest github/svn. Thanks, I did not see this
>> option
>
> Just recently, as in today.
>
>
> Mattias


Any idea what workarounds people used before? Surely someone used cmd.exe
before as an external tool in an older version.  I tend to not use the
latest version from source control. But I can, if I have to!
--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Launching External Tool Cmd.exe in Windows

shoKwave
In reply to this post by Lars
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

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus

lazarus.PNG (12K) Download Attachment
runner.lpr (818 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Launching External Tool Cmd.exe in Windows

Free Pascal - Lazarus mailing list
In reply to this post by Lars
On 23.09.2016 02:22, Lars wrote:

> On Thu, September 22, 2016 3:45 pm, Mattias Gaertner wrote:
>>> Oh, when did you add this, long ago or just recent... which release...
>>> or is it only on the latest github/svn. Thanks, I did not see this
>>> option
>>
>> Just recently, as in today.
>>
>>
>> Mattias
>
>
> Any idea what workarounds people used before? Surely someone used cmd.exe
> before as an external tool in an older version.  I tend to not use the
> latest version from source control. But I can, if I have to!
>

In Tools->Configure External tools...->Add dialog, input these:

Title : Command Prompt
Program Filename : $Env(COMSPEC)
Parameters : '/c "start "Command Prompt" "%COMSPEC%""'

If single line contains at least one space to separate parameters then
whole line will be enclosed with double quotes automatically, thus
making it one parameter option. Single quotes at the beginning and the
end will prevent this.

In Parameters text box, you can have multiple lines and those lines will
be one parameter per line.

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Launching External Tool Cmd.exe in Windows

Free Pascal - Lazarus mailing list
On Sat, September 24, 2016 11:06 pm, Cyrax via Lazarus wrote:

>> Any idea what workarounds people used before? Surely someone used
>> cmd.exe before as an external tool in an older version.  I tend to not
>> use the latest version from source control. But I can, if I have to!
>>
>
> In Tools->Configure External tools...->Add dialog, input these:
>
>
> Title : Command Prompt
> Program Filename : $Env(COMSPEC)
> Parameters : '/c "start "Command Prompt" "%COMSPEC%""'
>
>

Genius! Any idea how to launch a console app using this trick?


i.e. I develop a console app in lazarus (the $TargetFile()) and want to
launch it but leave it open. Cmd /k was what I thought.

 other option would be to make a ms dos batch file, that launches a
command window, and run it. Or like the other poster said, create a
launcher program
--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus