WinFix: Error 0xC0000142 – Windows Task Scheduler fails to run in Batch Mode

Setup Windows Task Scheduler in Batch Mode (i.e. Run whether user is logged on or not) may raise error 0xC0000142 even using a simple batch file to output to a file.

If the same task is set to run in interactive mode, the task runs successfully.


Running Windows Task Scheduler in Batch mode (i.e. “Run whether user is logged on or not”) fail with error 0xC0000142 but it run successfully in interactive mode.

Error Info

Error 0xC0000142 resolves to STATUS_DLL_INIT_FAILED in the native API.

In simple terms, this error raises as it was unable to load or initialize a critical DLL due to DLL mismatch, subsystem failure, or load successfully but fails to initialize.


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:


For Windows 2000 and above:

SharedSection uses the following format to specify the system and desktop heaps:

  1. The first SharedSection value (1024) defines the heap size common to all desktops. This includes the global handle table (Window handles are unique machine wide) and shared system settings (such as SystemMetrics). It is unlikely you would ever need to change this value.
  2. The second SharedSection value (3072) controls the size of the desktop heap that is associated with an interactive window station (used for Windows objects). This static value is used to prevent ill- behaved applications from consuming too many resources. Because the desktop heap is mapped into each process’ address space, this value should not be set to an arbitrarily high value (as it would decrease performance), but should only be increased sufficiently to allow all the desired applications to run.
  3. The third SharedSection value (512) controls the size of the desktop heap for each desktop that is associated with a “non-interactive” window station. If this value is not present, the size of the desktop heap for non-interactive window stations will be same as the size specified for interactive window stations (the second SharedSection value).

  • This registry value is only valid when the /3GB switch is not being used. The /3GB switch is specified in the boot.ini file.
  • Special care should be taken when modifying the desktop heap settings. Only adjust upwards in 256 or 512 increments until the desktop heap errors have been resolved. Adjusting these values too high could have a potentially negative impact on server performance because fewer non-interactive sessions can be established.


1. Run Registry Editor regedit.exe
2. Browse to the following key in the registry editor:
HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\SubSystems



3. 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
4. Locate the SharedSection parameter within the data of this value.  This parameter will have 3 or 4 values.
5. Increase the third SharedSection value incrementally by 256 or 512 until the issue resolved
6. Restart may be required to take effect.

Forum Articles:

  1. Download Windows task scheduler not running


  1. GENERAL ERROR: On a NetBackup 6.x or 7.0 server, errors occur in the application event log stating “Application Error : The application failed to initialize properly (0xc0000142). Click on OK to terminate the application.” This may occur for several different NetBackup processes
  2. “Out of Memory” error message appears when you have a large number of programs running
  3. App-V 5.0: On these 0xc0000142 errors and where they are coming from
  4. Out of Memory Error – Boot.ini 3GB Switch
  5. User32.dll or Kernel32.dll fails to initialize
  6. FRM-93552 and Windows Error – A desktop heap allocation failed

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.