0
i have a strange problem with the task scheduler under Windows Server 2016.
I create a task which triggered daily at 3am. This tasks only start a simple batch file which delete some files on a local drive. So nothing special.
The result by running this task is 0xC0000142. No matter if i start this task manually or it starts by windows at 3am.
But if i restart the whole server and start the task manually it works. The result is 0x0. I try to incease the "Windows SharedSection" via registry and restart, but nothing happens. The next morning i get the 0xC0000142 result.
My task in XML:
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2018-11-29T11:46:43.174076</Date>
<Author>ECB189B\Administrator</Author>
<URI>\Delete temp</URI>
</RegistrationInfo>
<Triggers>
<CalendarTrigger>
<StartBoundary>2018-11-29T03:00:00</StartBoundary>
<Enabled>true</Enabled>
<ScheduleByDay>
<DaysInterval>1</DaysInterval>
</ScheduleByDay>
</CalendarTrigger>
</Triggers>
<Principals>
<Principal id="Author">
<UserId>S-1-5-21-3460449123-1791338768-3707012617-500</UserId>
<LogonType>S4U</LogonType>
<RunLevel>HighestAvailable</RunLevel>
</Principal>
</Principals>
<Settings>
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
<AllowHardTerminate>true</AllowHardTerminate>
<StartWhenAvailable>false</StartWhenAvailable>
<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
<IdleSettings>
<StopOnIdleEnd>true</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
<AllowStartOnDemand>true</AllowStartOnDemand>
<Enabled>true</Enabled>
<Hidden>false</Hidden>
<RunOnlyIfIdle>false</RunOnlyIfIdle>
<DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteAppSession>
<UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine>
<WakeToRun>false</WakeToRun>
<ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
<Priority>7</Priority>
</Settings>
<Actions Context="Author">
<Exec>
<Command>C:\mybatch.bat</Command>
</Exec>
</Actions>
</Task>
My batch:
@ECHO OFF
del /Q /S C:\temp\*.*
This problem affect only one server. All other servers with the same task doesn't have this problem.
/EDIT
Okay i try something. I change RUN WHETHER USER IS LOGGED ON OR NOT to RUN ONLY WHEN USER IS LOGGED on. This works. I get no more error messages on running this task at 3am, but it isn't the solution. Why the RUN WHETHER USER IS LOGGED ON OR NOT mode doesn't work? I try the Administrator and the SYSTEM user.
Error 0xC0000142 usually means that the application was unable to start correctly. Maybe try to move the batch file to some folder, not in
C:
. – harrymc – 2019-08-06T16:52:37.557Try it. Same result : / – Athris – 2019-08-07T06:43:21.367
Check whether S4U account has these permissions: Logon as a batch job, Logon as a service. Note that when running at 3 AM, it's perhaps unlikely to have a signed-on user at this hour. – harrymc – 2019-08-07T08:32:07.410
I check the permissions. Everyone is fine. After one night it isn't even possible to run the task manually. Only a complete restart solve the problem for some hours. – Athris – 2019-08-07T08:40:15.667
Okay i try something. I change RUN WHETHER USER IS LOGGED ON OR NOT to RUN ONLY WHEN USER IS LOGGED on.
This works. I get no more error messages on running this task at 3am, but it isn't the solution.
Why the RUN WHETHER USER IS LOGGED ON OR NOT mode doesn't work? I try the Administrator and the SYSTEM user. – Athris – 2019-08-09T06:30:02.313