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 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:
- 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.
- 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.
- 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.
- 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
- “Out of Memory” error message appears when you have a large number of programs running
- App-V 5.0: On these 0xc0000142 errors and where they are coming from
- Out of Memory Error – Boot.ini 3GB Switch
- User32.dll or Kernel32.dll fails to initialize
- FRM-93552 and Windows Error – A desktop heap allocation failed