I plan to run specific application commands every X days using Task Scheduler. Do I have to write support for command-line parameters first, so Scheduler can execute it?
If so, does anyone know any good command-parameter components?
I plan to run specific application commands every X days using Task Scheduler. Do I have to write support for command-line parameters first, so Scheduler can execute it?
If so, does anyone know any good command-parameter components?
Why not us the built in Windows Scheduler for this?
--jeroen
VCL Scheduling Agent is a wrapper for Microsoft Task Scheduler API
If you just want to read any cmd line parameters that were passed to your application at start-up you can use Delphi's inbuild functions.
ParamCount // Number of cmd params passed at startup
ParamStr(0) // string of param zero
So calling you program like so
c:\myapp.exe -foo -bar
would give the following result
ParamStr(0) = c:\myapp.exe
ParamStr(1) = -foo
ParamStr(2) = -bar
You may wish to consider the FindCmdLineSwitch from the SysUtils unit.
function FindCmdLineSwitch(const SwitchValue:string):Boolean;
function FindCmdLineSwitch(const SwitchValue:string; IgnoreCase:Boolean):Boolean;
function FindCmdLineSwitch(const SwitchValue:string; SwitchChars:TSysCharSet; IgnoreCase:Boolean):Boolean;
This allows to check for the presence of a command line switch, specify whether to ignore its case and optionally use different switch characters e.g. '-' or '/'