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.
according to http://blog.ylnotes.com/winfix-error-0xc0000142-windows-task-scheduler-fails-to-run-in-batch-mode/
Windows Task Scheduler fails to run in batch mode when the machine has run out of non-interactive desktop heap space. Rebooting the server may rectify the temporary problem until the desktop heap is again exhausted. Adjusting the size of the non-interactive desktop heap has been known to resolve this error permanently.
Desktop Heap Info Default Desktop heap settings: Windows 32-bit servers: SharedSection=1024,3072,512 Windows 64-bit servers: SharedSection=1024,20480,768
For Windows NT:
SharedSection specifies the system and desktop heaps using the following format:
SharedSection=xxxx,yyyy For Windows 2000 and above:
SharedSection uses the following format to specify the system and desktop heaps:
SharedSection=xxxx,yyyy,zzzz
to FIX:
Run Registry Editor regedit.exe
Browse to the following key in the registry editor: HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\SubSystems
Click to modify the SubSystems\Windows value. %SystemRoot%\system32\csrss.exe ObjectDirectory=\Windows SharedSection=1024,20480,768 Windows=On SubSystemType=Windows ServerDll=basesrv,1 ServerDll=winsrv:UserServerDllInitialization,3 ServerDll=winsrv:ConServerDllInitialization,2 ServerDll=sxssrv,4 ProfileControl=Off MaxRequestThreads=16
Locate the SharedSection parameter within the data of this value. This parameter will have 3 or 4 values.
Increase the third SharedSection value incrementally by 256 or 512 until the issue resolved
Restart may be required to take effect.
User contributions licensed under CC BY-SA 3.0