Recent

Author Topic: How to execute a program using a script  (Read 2328 times)

Roland57

  • Sr. Member
  • ****
  • Posts: 421
    • msegui.net
How to execute a program using a script
« on: February 04, 2022, 12:06:44 pm »
Hello!

I use Lazarus under Windows on a USB key. I have several projects using Cairo. The Cairo binaries are somewhere on my USB key. I don't want to paste them in each directory.

So I wrote this batch file, that I call for example run.cmd:
Code: Text  [Select][+][-]
  1. @echo off
  2.  
  3. set CAIROBIN=%~d0\applications\compilateurs\newpascal\lazarus\
  4. set PATH=%PATH%;%CAIROBIN%
  5.  
  6. %1

So I can open a command prompt and type run my-cairo-program.exe.

How can I use my script from the IDE? I see that it is possible, in project options, to execute a command, but I don't see how I can get the name of the executable (the parameter for my batch script).
My projects are on Gitlab and on Codeberg.

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: How to execute a program using a script
« Reply #1 on: February 04, 2022, 10:37:48 pm »
See Compiler Commands.

I'd try putting your batch file in the Execute AFTER Compile + Build and uncheck Run (untested).

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: How to execute a program using a script
« Reply #2 on: February 05, 2022, 12:54:24 am »
Or you can use External Tools, which gives you more control over the process. Like show/hide console window, add shortcut,..etc.

Either way you need $TargetFile() or $OutputFile() as a parameter

Roland57

  • Sr. Member
  • ****
  • Posts: 421
    • msegui.net
Re: How to execute a program using a script
« Reply #3 on: February 05, 2022, 03:33:14 am »
@trev, engkin

Thanks.
My projects are on Gitlab and on Codeberg.

Roland57

  • Sr. Member
  • ****
  • Posts: 421
    • msegui.net
Re: How to execute a program using a script
« Reply #4 on: February 21, 2022, 12:51:58 pm »
I could finally test your suggestions. (I didn't have a Windows system under the hand last two weeks.)

I'd try putting your batch file in the Execute AFTER Compile + Build and uncheck Run (untested).

Yes, it works (image 1).

Or you can use External Tools, which gives you more control over the process. Like show/hide console window, add shortcut,..etc.

Either way you need $TargetFile() or $OutputFile() as a parameter

It works too (image 2).

Thanks again.


« Last Edit: February 21, 2022, 02:41:22 pm by Roland57 »
My projects are on Gitlab and on Codeberg.

 

TinyPortal © 2005-2018