Recent

Author Topic: Is it possible to run batch file with a keypress ?  (Read 1403 times)

egsuh

  • Hero Member
  • *****
  • Posts: 860
Is it possible to run batch file with a keypress ?
« on: October 08, 2021, 08:14:42 am »
On Windows 10,

I'd like to run some specific applications (e.g. FCGI or HTTPServer application) in following way:

- first stop the server
- Compile the file
- Start the server

with just pressing F9,  etc.

Is this possible?

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1684
  • Former Delphi 1-7, 10.2 user
Re: Is it possible to run batch file with a keypress ?
« Reply #1 on: October 08, 2021, 08:58:30 am »
I think so - see Project Options > Compiler Options for optional Execute BEFORE and Execute AFTER commands.
Lazarus 2.3, FPC 3.3.1 macOS 12.0.1 x86_64 Xcode 13.1
Lazarus 2.3, FPC 3.3.1 macOS 12.0.1 aarch64 Xcode 13.1
Lazarus 2.3, FPC 3.2.2 FreeBSD 13.0 amd64 VM
Lazarus 2.3, FPC 3.2.2 FreeBSD 12.2 amd64 VM
Lazarus 2.1 r61574 FPC 3.0.4 Ubuntu 20.04 VM
Lazarus 2.0.10 FPC 3.2.0 Win10 VM

devEric69

  • Hero Member
  • *****
  • Posts: 644
Re: Is it possible to run batch file with a keypress ?
« Reply #2 on: October 08, 2021, 01:45:46 pm »
As already said, in Options for project, Compiler commands, just check (on)"Build" in (on)"Execute after", and paste your command line in order to call your *.bat file. For information (under Linux anyway) the script cannot be interactive e.g. "read sResponse; case "$sResponse ...\...". I'm using one, just to copy and paste the compiled *.elf into a kind of "files server directory" (could be a "CGI-bin directory"). And the last script's echo cmd should\will be displayed at the end\after of the compilation, in the Lazarus IDE itself.
use: Linux 64 bits (Ubuntu 20.04 LTS).
Lazarus version: 2.0.4 (svn revision: 62502M) compiled with fpc 3.0.4 - fpDebug \ Dwarf3.

egsuh

  • Hero Member
  • *****
  • Posts: 860
Re: Is it possible to run batch file with a keypress ?
« Reply #3 on: October 10, 2021, 10:38:21 am »
Thank you for your replies.
I have set up the "Compiler Command" options. 
I cannot enter all the command directly. My command is:

         d:\nssm\nssm.exe stop aqrun 

But using above command directly in the ExecuteBefore.command did not work. I tried to quote with single quotation and double quotation, but none of them worked.

So, I put my command in the batch file named StartAQRun.bat, and called it in the BeforeExecute.command. This works.

 

TinyPortal © 2005-2018