Whenever I leave my computer idle for a few minutes I come back and my Process Explorer shows that 'ngen.exe' is running and occupying 2 of my 4 cpus.

Question: Is there a way to turn NGEN.exe off as a background task?

I'd like to (as do many others on the internet) compile all the .net binaries all at once instead of having the computer 'automatically' doing so every time I leave the computer idle. I've checked throughout Microsoft forums and so far nobody has a complete answer to this problem, and many are having the same issues.

Apparently some library in .net framework is needing to be recompiled and it gets 'stuck' and puts the CPU into high and loops over and over again.

I've just experienced this same issue and there is another thread attempts to answer it but it is incomplete

Regedit of /HKLM/SOFTWARE/Microsoft/Windows/Current Version/RUN has no entry to run the .net compiler. Something else must be causing ngen.exe to trigger.

Can someone post other locations that might be triggering this to run?

I'd like to turn it off as I'm sure many others would. I also disabled automatic updates in Windows 10.

UPDATE: Process explorer says this is what is running:

"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\ngen.exe" uninstall "C:\WINDOWS\assembly\NativeImages_v4.0.30319_64\Microsoft.Vf‌​9a08577#\328b1bc4205‌​c08821860805bf5e6c99‌​e\Microsoft.VisualSt‌​udio.Tools.Applicati‌​ons.Hosting.ni.dll" /noroot /LegacyServiceBehavior – Viktor 5 mins ago

"C:\Windows\Microsoft.NET\Framework\v4.0.30319\ngen.exe" uninstall "C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\Presentation‌​Framewo#\7fa93028119‌​b98117acfd5ea18f15c1‌​3\PresentationFramew‌​ork.ni.dll" /noroot /LegacyServiceBehavior – Viktor 4 mins ago edit

"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\ngen.exe" uninstall "C:\WINDOWS\assembly\NativeImages_v2.0.50727_64\Microsoft.PowerShel#\23dfb41f48958215c80bbbc0c9177cb2\Microsoft.PowerShell.Commands.Utility.ni.dll" /noroot /LegacyServiceBehavior

It keeps running over and over and over again. - that's the output from Process explorer. Its extremely annoying and it seems to happen EVERY TIME I leave my desk.

QUESTION: it seems like these are legitimate processes. Does anyone know a way to manually remove those uninstall commands and compile the .net framework completely 1 time instead of having it loop over and over again?

CURRENTLY TESTING: I killed the process and ngentask.exe then went to Windows\assembly and moved those Native Image folders to a temporary directory. I'll keep you posted if it starts back up again. Chances are if the NativeImages folders are missing it won't try to keep uninstalling those assemblies.


2 Answers 2


Download the Easy NGEN Script, run it as admin and select option 1 to do a full ngen run:

enter image description here

This takes alot of time and does all pending ngen operations. After this the ngen queue is empty and you shouldn't see the other tasks again.

  • 6
    @pijemcolu why is this an issue for you? open it in editor and you see it calls "%windir%\Microsoft.NET\Framework\v4.0.30319\ngen.exe" update /force entering a number is easier compared to remember this long command * facepalm* Nov 7, 2017 at 16:45
  • I always run this update /force after installing .net updates for Windows 10. Dec 3, 2019 at 15:50

Deleting a key in the registry is what finally worked for me. The problem was that ngen would try to keep reallocating memory over and over for the same corrupt DLL in the registry. It would eventually use up all the available memory on the computer.

Deleting the key "\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft.NETFramework\v2.0.50727\NGenService\Roots" worked for me. Stopping the scheduled task or killing ngen.exe is just a temporary measure and doesn't address the problem.

How Microsoft could let a problem like this go on for so long is beyond me. Today was the first day a search resulted in an answer for me.

More information on the problem can be found here https://aloiskraus.wordpress.com/2017/12/13/the-case-of-ngen-exe-needing-50-gb-of-memory/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.