A scheduled task can run an SD command, and only the commands an administrator has named for it.
Typing a command after sd — sd my.report — needs an elevated session. A
scheduled task does not run that way, so without a list there would be no way to
have SD do anything on a timer without handing the job administrator rights.
There are two ways past that:
| an elevated session | runs anything, exactly as before |
| anything else | runs what is listed for its account in the SD system file batch.jobs |
Nothing changes for a session you type at. Commands entered at the :
prompt are unaffected, and so is plain sd with no command after it.
There is no password anywhere in this. The job signs in as its own Windows account and SD puts it in the matching SD account, exactly as it would for a person at a keyboard. Nothing has to store a credential for the job to use, and the job grants nobody anything — no other account is in its group.
The permit list#
batch.jobs is a directory file in C:\ProgramData\SD\sdsys, so one record
per account, named after the account, holding one command name per line.
Only an administrator can change it. It is read-only to SD users, by the same control and the same script that locks the other permit files — a user who could add a line to their own record would be granting themselves the command line.
It is keyed by the account you end up in, not by the Windows account name,
and the two are usually the same. sd -a<name> cannot be used to reach
somebody else's list: that form is refused unless the account is your own.
Any account can be given a list. Every account has the same VOC now, so
there is nothing about the account type to consider here; the account's
record in batch.jobs is what decides what it may run. SDSYS itself has
no list: its sessions run anything.
Both shapes of record are read — one name per line, and a multivalued field 1 —
so a record written with ed and a record written by a program agree. A name
still has to match exactly.
What may be listed#
Two rules, and both are tested when the command runs rather than when it is listed:
1. A single name with nothing after it. my.report may be listed;
my.report yesterday may not, and neither will run:
A command run from the command line must be a single name with nothing
after it. Put anything the job needs to vary inside the paragraph or
sentence being run.
That is the rule doing the security work. "It must be in the VOC" would be worth nothing on its own — every verb is a VOC entry — so it is the absence of arguments that stops a listed name being turned into something else.
2. A paragraph or a sentence in that account. A VOC entry of type PA or
S. Anything else — a verb, a file pointer — is refused by name:
my.report has to be a paragraph or a sentence in this account to be run
from the command line, and it is neither.
Setting one up#
Four steps, and the first and third need an administrator for a new account.
1. Write the work as a paragraph in the account that will run it. A PA
record in that account's VOC, with the commands on the lines after the type:
:ed voc my.report
Saving a record of the VOC needs the account to hold voc-on, which a new
account does not have. SDSYS gives it with modify.account name voc-on
(see Managing accounts); accounts that existed
at an upgrade have it already.
2. Check it runs when you type it, in that account, before putting it on a timer.
3. Add the name to the account's list, signed in to Windows as SDSYS, elevated:
:set.batch add fred my.report
my.report may now be run from the command line in account fred
set.batch checks that the name is a paragraph or a sentence in that
account before it adds it, writes the account's record in batch.jobs,
and records the change in the audit trail. set.batch remove fred my.report
takes it off, and set.batch alone lists every account's commands. The
administrator's own account has no list. Nothing is allowed as delivered.
Or use the Scheduled jobs page, tool.jobs. It lists every account
with the number of commands it may run this way. F6 or Enter moves to
the account's paragraphs and sentences, each marked as allowed or not.
Enter on one shows the set.batch command and what it does, and runs it
only when you answer Run. A name still on the list whose VOC record has
gone, or is no longer a paragraph or a sentence, is shown as such, and
Enter takes it off. A name holding a character other than a lower-case
letter, a digit, a dot, a dash or an underscore cannot be sent from the
page: it shows the set.batch command to type at the prompt.
The page does not write an account's schedule: step 4 is done in Task Scheduler. (The page's Jobs view, below, schedules the administrator's own jobs.)
batch.jobs can still be edited directly (ed batch.jobs fred, one
command name per line), but set.batch makes the same checks the login
makes, so a mistake shows up when you make it, not at the job's first
run.
4. Create the scheduled task. Windows Task Scheduler runs it; two fields carry the whole of it:
| Program/script | C:\Program Files\SD\usr\bin\sd.exe |
| Add arguments | my.report |
The task runs as a Windows account, and that account needs a matching SD account — that is the whole of the sign-in. There is no password to configure anywhere in SD for it.
Do not tick "run with highest privileges". It is not needed, and the
whole point of batch.jobs is a job that runs without administrator rights. A
task that is elevated passes the gate on elevation alone and never consults the
list, so it would also be a job nobody had approved a command for.
Use a Windows account you already had — that is the case the design was
built around. Accounts that create.account makes are denied interactive
logon at this machine on purpose, which Task Scheduler may or may not accept as
the identity a task runs as.
When it refuses#
It fails closed. Every path that does not reach the end of the check leaves the command refused, and each one writes a reason to the audit trail:
| What is wrong | Recorded as |
|---|---|
| the command line carried an argument | command line carried arguments |
batch.jobs is missing or unreadable |
batch.jobs could not be opened |
| the name is not in this account's record | command is not on the account list |
| the name has no VOC entry at all | no VOC record for the command |
it has one, but it is not PA or S |
VOC type is not PA or S |
The message on the screen for the third of those names both the command and the account, and says where an administrator grants it:
my.report is not a command that account fred may run from the command line.
An administrator grants it by adding the name to the account's record in
the SD system file batch.jobs, which only an administrator can change.
A refusal is not a hang. sd <command> is never asked to set a
password it cannot answer — see Running SD.
The administrator's own jobs#
Work that has to reach every account runs as the administrator, and only as one of two fixed jobs. An account's own job runs with that account's rights; the administrator's jobs are for what no single account may do:
| Job | Runs |
|---|---|
backup-all |
backup.account all |
update-accounts |
update.accounts all |
Nothing is scheduled as delivered. Each job is a Windows Task Scheduler task
that only the job helper, run by the SDSYS session, can set; the sdsys user may
not use schtasks for it. At each run the task starts sd with the job's command,
and SD makes it the administrator only when the run is that task's and the
definition names exactly that command. Every line the run writes to the audit
trail ends job=name. A run missed while the machine was off is not made up;
times are the machine's.
A schedule is one of five shapes: every 5, 10, 15, 20 or
30 minutes; hourly; daily hh:mm; weekly mon..sun hh:mm;
monthly 1..28 hh:mm.
SDSYS sets them up with set.job at the prompt, or in the Jobs view
of tool.jobs (J):
:set.job add nightly backup-all daily 02:30
sd-jobs: job nightly created
sd-jobs: job nightly is scheduled: daily 02:30
set.job alone lists the jobs with their next and last runs;
set.job change, delete and run do the rest. Everything else — the
page's keys, what a damaged job is, how a run is recognized, where the
definition is kept — is in the Administrator set's Scheduled jobs.