How can a DOS Batch command file determine if it is being run by Task Scheduler?
Asked
Active
Viewed 1,077 times
1
-
You could output the script results in a log file with timestamps. – vn. Jun 08 '16 at 18:03
2 Answers
1
If you control both the batch and the scheduled task, you could configure it to use a parameter.
Example - in the Scheduled Task, on the Action, you could define a parameter like: /ScheduledTask
In the batch file, you could check for the existence of the command-line parameter:
if /i %1==/ScheduledTask set RUN_BY_TASK_SCHEDULER=1
Related:

Jason Walker
- 37
- 4
0
maybe if the task was scheduled with another account, local or domain.
Inserting an IF based on enviroment variables like %userdomain% or %username%
Regards!

Ozwaldo Ortiz
- 51
- 4