1

How can a DOS Batch command file determine if it is being run by Task Scheduler?

1
  • You could output the script results in a log file with timestamps. Commented Jun 8, 2016 at 18:03

2 Answers 2

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:

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!

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.