views:

344

answers:

4

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?

+1  A: 

Why not us the built in Windows Scheduler for this?

--jeroen

Jeroen Pluimers
How do you create cmd parameters?
Tom
@Tom: see Mohammed's answer.
Jeroen Pluimers
Jeroen, I think that's exactly what he plans to do. He just doesn't know how to make his program understand the commands that Task Scheduler is going to invoke.
Rob Kennedy
+2  A: 

VCL Scheduling Agent is a wrapper for Microsoft Task Scheduler API

Mohammed Nasman
+8  A: 

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
Re0sless
+3  A: 

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 '/'

Simon Temlett