Task Scheduler is failing to execute Batch File when set to "logged in or not". This was working until a couple weeks ago

jed 41 Reputation points
2023-08-30T18:26:42.0366667+00:00

I have a batch script that runs robocopy on a folder to archive files to a network drive, on a Windows 10 Pro machine; (Note: These machines are on a domain, but have been disconnected from the domain at a client site for long time. This has not been a problem so far, but maybe this is the issue below?)

8 months ago I set up a bunch of machines to run this script. I set up a task to do so, and to make sure it doesn't bother the user, it's set to run under a local admin account ("itadmin") every 5 minutes.

This has been running without issue on all these machines for months. Also, it runs fine as the logged in user, but that causes a flash on the screen as the cmd window opens. Also, I can run the batch file as the logged in user manually, and also as the logged in user or the itadmin account using runas.

This week I logged in, and it appears there has been some windows update. Because now Task Scheduler is reporting error 0xC0000142 when the task is triggered. I updated to run as the logged in user without changing anything else and it's fine.

Did something change? Some security setting? I can't find any help on this.

thanks!

Windows for business Windows Client for IT Pros User experience Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. MotoX80 36,291 Reputation points
    2023-08-30T20:56:34.39+00:00

    Configure the task to capture a log. Have the task execute program "cmd.exe".

    In the arguments field set it like this example:

    /c C:\Scripts\MyScript.bat 1>>"C:\Scripts\Logs\MyScript-%date:~10,4%-%date:~4,2%%date:~7,2%.log" 2>&1

    That will create a daily log file of all executions of the task. That will capture stdout and stderr for programs that get called. Review the log to see what output robocopy produces.

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.