This problem has been identified when running command prompts in a non-interactive mode.
Microsoft has identified this to be non-interactive desktop heap size.
IMPORTANT: This article contains information about modifying the registry.
Before you modify the registry, make sure to create a back up of the registry and ensure that you understand how to restore the registry if a problem may occur.
For more information about how to back up, restore, and edit the registry, please review the relevant Microsoft Knowledge Base articles on support.microsoft.com.
In the registry, increase the non-interactive desktop heap using microsoft
KB126962 and KB184802.
The above KB are available at;