Hi @S, Ananth ,
It is difficult to point to a single exact cause without analyzing system traces, but based on similar issues, the extra checking from Device Guard and Antimalware is likely the problem. You can check a few things below:
1. Antimalware Inspection Delays (Defender + WDAC)
ReadFile() is waiting longer to receive the ERROR_BROKEN_PIPE state usually means that the write end of the anonymous pipe is being kept open longer than expected.
- On Windows 11 with Device Guard enabled, security components like Windows Defender's Real-Time Protection (RTP) and its file system filter (
AMFilter) often perform much deeper, synchronous scanning for every newcmd.exeor.batprocess created. - While these security processes inspect the child environment, they can temporarily hold onto the inherited pipe handles, delaying the process termination and the
ERROR_BROKEN_PIPEsignal. - A quick troubleshooting step is to try adding a temporary folder exclusion in Windows Security (for the directory containing your
.batscripts or the parent application). If the runtime drops from 30 minutes back to 5-7 minutes, the Antimalware inspection under the Device Guard environment is your bottleneck.
2. Code Integrity (CI) and HVCI Overhead
Windows 11 has updated and applied stricter enforcement for VBS and HVCI (Memory Integrity). Even if there are no audit/block events, the image validation process (calculating hashes, checking signatures) inside ci.dll during CreateProcess can consume more resources compared to Windows 10. When your application repeatedly spawns hundreds of short-lived child processes, this overhead accumulates very quickly.
3. Suggested Diagnostic Tools To see exactly what Windows 11 is doing during that 20-35 minute window, capturing an Event Tracing for Windows (ETW) log is the best approach. I suggest recording the trace by these steps below:
- Open the Start menu, type wprui (Windows Performance Recorder), and select Run as administrator.
- Click on More options. Then, under "Select additional profiles", expand Resource Analysis and check CPU usage along with File I/O activity. (You can uncheck First level triage).
- On the right side, change the Logging mode from Memory to File.
- Click Start. (If the software throws an "Access Denied - 0x80070005" error, it proves that your strict WDAC policy completely blocks ETW tracing, and you may need to test this on a machine with Device Guard configured in Audit mode).
- Reproduce the slow
CreateProcessbehavior for about 5 to 8 minutes, then click Save in the WPR window to output the.etltrace file.
Afterward, you can open this .etl file using Windows Performance Analyzer (WPA):
- Open the System Activity -> Generic Events graph. Look at the
Provider Namecolumn. - Check if providers like
Microsoft-Antimalware-Engine,Microsoft-Antimalware-RTP, orMicrosoft-Windows-CodeIntegrityshow massive event counts that align perfectly with theMicrosoft-Windows-Kernel-Process(process creation) events.
Hope these suggestions help narrow down the issue. If you found my response helpful or informative, I would greatly appreciate it if you could provide feedback by following this guide.
Thank you.