For an interactive process, SYS$COMMAND always points to your terminal, unless you explicitly redirect it. For a batch job, SYS$COMMAND always points to the current procedure.
SYS$COMMAND can be redirected using DEFINE (or ASSIGN). If DEFINEd in /USER mode, it will be DEASSIGNed when a program is run and that program terminates. If DEFINEd in /SUPERVISOR mode (the default if no access mode is specified in the DEFINE (or ASSIGN) command) or an “inner” (more privileged) mode, it remains in effect until explicitly DEASSIGNed.