Recent

Author Topic: Execute external Programm with passing it Parameters ?  (Read 855 times)

Weitentaaal

  • Hero Member
  • *****
  • Posts: 554
Execute external Programm with passing it Parameters ?
« on: January 29, 2021, 08:36:14 am »
Hello :)

Can i Use TProcess.CommandLine(#.exe param1 param2) like that ?
or is there some other way to execute external executables with params ?

Thanks for any reply :)

dsiders

  • Hero Member
  • *****
  • Posts: 1491
Re: Execute external Programm with passing it Parameters ?
« Reply #1 on: January 29, 2021, 08:44:47 am »
Hello :)

Can i Use TProcess.CommandLine(#.exe param1 param2) like that ?
or is there some other way to execute external executables with params ?

Thanks for any reply :)

Is there something that the docs did not cover?

https://www.freepascal.org/docs-html/current/fcl/process/tprocess.html
https://www.freepascal.org/docs-html/current/fcl/process/tprocess.executable.html
https://www.freepascal.org/docs-html/current/fcl/process/tprocess.parameters.html

Preview the next Lazarus documentation release at: https://dsiders.gitlab.io/lazdocsnext

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Execute external Programm with passing it Parameters ?
« Reply #2 on: January 29, 2021, 08:47:41 am »
You can but CommandLine is deprecated and will probably dissapear soon. Instead, you should use Executable and Parameters.

See the FCL documentation, and the TProcess section in the wiki page on Executing External Programs to see them in use.

If for some reason you have to start from a full command line, you can find a couple helpful functions in LazFileUtils: SplitCmdLine() and SplitCmdLineParams()

HTH!
« Last Edit: January 29, 2021, 08:50:48 am by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Weitentaaal

  • Hero Member
  • *****
  • Posts: 554
Re: Execute external Programm with passing it Parameters ?
« Reply #3 on: January 29, 2021, 08:57:24 am »
Thank You Guys :)

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12563
  • FPC developer.
Re: Execute external Programm with passing it Parameters ?
« Reply #4 on: January 29, 2021, 10:50:30 am »
And see if Runcommand satisfies your needs before rolling your own.

 

TinyPortal © 2005-2018