ngen.exe 高CPU Windows 10 - アセンブリのアンインストール無限ループ

ngen.exe 高CPU Windows 10 - アセンブリのアンインストール無限ループ

コンピュータを数分間アイドル状態にしておくと、戻ってくるたびに、プロセス エクスプローラーに「ngen.exe」が実行中で、4 つの CPU のうち 2 つを占有していることが表示されます。

質問: NGEN.exe をバックグラウンド タスクとしてオフにする方法はありますか?

私は (インターネット上の他の多くの人と同じように)、コンピュータをアイドル状態にするたびにコンピュータが「自動的に」コンパイルするのではなく、すべての .net バイナリを一度にコンパイルしたいと考えています。Microsoft フォーラム全体で確認しましたが、今のところこの問題に対する完全な答えを持っている人はおらず、多くの人が同じ問題を抱えています。

どうやら、.net フレームワーク内の一部のライブラリを再コンパイルする必要があり、それが「スタック」して CPU 使用率が高くなり、何度もループするようです。

私も同じ問題を経験したばかりですが、別のスレッドがあります答えようとしているが不完全である

/HKLM/SOFTWARE/Microsoft/Windows/Current Version/RUN の Regedit には、.net コンパイラを実行するためのエントリがありません。ngen.exe がトリガーされる原因は他に何かあるはずです。

この現象が発生する原因となっている可能性のある他の場所を投稿してもらえますか?

他の多くの人と同じように、私はこれをオフにしたいと思います。また、Windows 10 の自動更新も無効にしました。

更新: プロセス エクスプローラーによると、実行中のものは次のとおりです:

"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\ngen.exe" をアンインストールして "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 分前

"C:\Windows\Microsoft.NET\Framework\v4.0.30319\ngen.exe" アンインストール "C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\Presentation‌​Framewo#\7fa93028119‌​b98117acfd5ea18f15c1‌​3\PresentationFramew‌​ork.ni.dll" /noroot /LegacyServiceBehavior – Viktor 4 分前 編集

"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\ngen.exe" をアンインストールし、"C:\WINDOWS\assembly\NativeImages_v2.0.50727_64\Microsoft.PowerShel#\23dfb41f48958215c80bbbc0c9177cb2\Microsoft.PowerShell.Commands.Utility.ni.dll" /noroot /LegacyServiceBehavior を実行します。

何度も何度も実行され続けます。 - これは Process Explorer からの出力です。これは非常に迷惑で、デスクを離れるたびに発生するようです。

質問: これらは正当なプロセスのようです。これらのアンインストール コマンドを手動で削除し、ループを何度も繰り返すのではなく、.net フレームワークを 1 回で完全にコンパイルする方法を知っている人はいますか?

現在テスト中: プロセスと ngentask.exe を終了し、Windows\assembly に移動して、それらの Native Image フォルダーを一時ディレクトリに移動しました。再起動したら、お知らせします。NativeImages フォルダーが見つからない場合、それらのアセンブリをアンインストールし続けることはないと思われます。

答え1

簡単なNGENスクリプトをダウンロードする管理者として実行し、オプション 1 を選択して完全な ngen 実行を実行します。

ここに画像の説明を入力してください

これには多くの時間がかかり、保留中のすべての ngen 操作を実行します。この後、ngen キューは空になり、他のタスクは再び表示されなくなります。

(リンクが機能しない場合は、コードをコピーして txt ファイルに貼り付け、名前を cmd に変更します)。

@echo off
title Easy Ngen Runner v5 for '.NET 4.x series' by Burf

"%windir%\system32\reg.exe" query "HKU\S-1-5-19" >nul 2>&1 && (
goto :admincheckok
) || (
echo      -------
echo  *** WARNING ***
echo      -------
echo.
echo.
echo ADMINISTRATOR PRIVILEGES NOT DETECTED!
call :line
echo.
echo.
echo This script must be run with administrator privileges!
echo.
echo To do so, right click on this script and select 'Run As Administrator'
echo.
goto :fin
)

:admincheckok

"%windir%\system32\reg.exe" query "hklm\software\microsoft\Windows NT\currentversion" /v buildlabex >"%temp%\os.txt"
find /i "AMD64" <"%temp%\os.txt">nul
if %errorlevel% equ 0 (set arch=x64) else (set arch=x86)

for /f "tokens=3* delims= " %%G in ('reg query "hklm\software\microsoft\Windows NT\currentversion" /v productname') do (set winv=%%G %%H)
echo %winv%|find /i "Windows 10" >nul
if errorlevel 0 (set w10=1&for /f "tokens=3" %%G in ('reg query "hklm\software\microsoft\Windows NT\currentversion" /v UBR') do (set /a UBR=%%G))
if defined w10 (for /f "skip=2 tokens=3,4,6,7 delims=. " %%G in ('type "%temp%\os.txt"') do (set "win=%winv% %arch% Build %%G.%UBR% {%%I %%J}")
) else (
for /f "skip=2 tokens=3,4,6,7 delims=. " %%G in ('type "%temp%\os.txt"') do (set "win=Legacy %winv% %arch% Build %%G.%%H {%%I %%J}")
)
del "%temp%\os.txt"

if not exist "%windir%\Microsoft.NET\Framework\v4.0.30319" goto :notinstalled

:menu
call :title
echo.
echo 1. Run full Ngen 'update' task
echo.
echo 2. Run standard Ngen 'update' task
echo.
echo 3. Execute queued Ngen items (what Windows does in background)
echo.
echo 4. Visit the 'homepage' of Burf:
echo    (http://1drv.ms/1oVTfju)
echo.
echo 5. Information
echo.
echo 6. Exit
echo.
echo. 
echo.
choice /c 123456 /N /M "Please enter your selection> "
if errorlevel 6 goto :eof
if errorlevel 5 goto :info
if errorlevel 4 start http://1drv.ms/1oVTfju&goto :menu
if errorlevel 3 goto :ngub
if errorlevel 2 goto :ngus
if errorlevel 1 goto :nguf


:info
call :title
echo This script allows your to easily run the .NET Framework tool Ngen
echo (Native Image Generator) program.
echo.
echo The three options in the menu represent the three different methods in
echo which is can be run:
echo Menu option 1 - Recreates all images
echo Menu option 2 - Processes images that have become invalid
echo Menu option 3 - Execute items already in queue to be processed by Windows
echo.
echo Option 1 is really only beneficial after a .NET Framework or a major Windows
echo update has been installed. Option 3 executes those items already in the
echo queue, this just processes the items immediately instead of during idle
echo processor time.
echo.
echo Option 2 should be used for general use, option 1 after a .NET Framework
echo or major Windows update (including Insider Previews), and option 3 is
echo only provided for completeness of this script. It is the 'least useful'.
echo.
echo It makes sense to have queued items processed and native images updated
echo before they are actually required!
echo.
echo.
echo Press any key to return to menu...
pause >nul
goto :menu


:nguf
call :title
echo Running x86 update item task. Some 'errors' may show, this is expected.
call :line
echo.
"%windir%\Microsoft.NET\Framework\v4.0.30319\ngen.exe" update /force
if defined task (
"%windir%\Microsoft.NET\Framework\v4.0.30319\ngentask.exe" /runtimewide
)
echo.
if %arch% equ x86 (goto :nudone)
echo.
echo Now running x64 update item task. Some 'errors' may show, this is expected.
call :line
echo.
"%windir%\Microsoft.NET\Framework64\v4.0.30319\ngen.exe" update /force
if defined task (
"%windir%\Microsoft.NET\Framework64\v4.0.30319\ngentask.exe" /runtimewide
)
goto :nudone


:ngus
call :title
echo Running x86 update item task. Some 'errors' may show, this is expected.
call :line
echo.
"%windir%\Microsoft.NET\Framework\v4.0.30319\ngen.exe" update
if defined task (
"%windir%\Microsoft.NET\Framework\v4.0.30319\ngentask.exe" /runtimewide
)


echo.
if %arch% equ x86 (goto :nudone)
echo.
echo Now running x64 update item task. Some 'errors' may show, this is expected.
call :line
echo.
"%windir%\Microsoft.NET\Framework64\v4.0.30319\ngen.exe" update
if defined task (
"%windir%\Microsoft.NET\Framework64\v4.0.30319\ngentask.exe" /runtimewide
)
goto :nudone


:ngub
call :title
echo Running x86 update item task. Some 'errors' may show, this is expected.
call :line
echo.
"%windir%\Microsoft.NET\Framework\v4.0.30319\ngen.exe" executequeueditems
if defined task (
"%windir%\Microsoft.NET\Framework\v4.0.30319\ngentask.exe" /runtimewide
)


echo.
if %arch% equ x86 (goto :nudone)
echo.
echo Now running x64 update item task. Some 'errors' may show, this is expected.
call :line
echo.
"%windir%\Microsoft.NET\Framework64\v4.0.30319\ngen.exe" executequeueditems
if defined task (
"%windir%\Microsoft.NET\Framework64\v4.0.30319\ngentask.exe" /runtimewide
)
goto :nudone


:nudone
echo.
echo.
echo Done! Please note that some 'errors' may have appeared. These are, for the
echo most part, not unexpected and are not deemed critical.
echo.
goto :fin


:title
cls
echo -----------------------------------------
echo Easy Ngen Runner v5 for '.NET 4.x' series by Burf
echo -----------------------------------------
echo %win%
echo.
goto :eof


:fin
echo.
echo Press any key to exit...
pause >nul
goto :eof


:notinstalled
echo Microsoft .NET Framework 4, 4.5, 4.6, or 4.7 NOT detected. Please install before
echo using this script. If already installed, something may be 'wrong'...
goto :fin


:line
echo ____________________________________________________________________________
goto :eof

答え2

レジストリ内のキーを削除すると、最終的にうまくいきました。問題は、ngen がレジストリ内の同じ破損した DLL に対してメモリを何度も再割り当てしようとすることでした。最終的には、コンピューター上の使用可能なメモリがすべて使い果たされてしまいます。

キー「\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft.NETFramework\v2.0.50727\NGenService\Roots」を削除すると、問題は解決しました。スケジュールされたタスクを停止したり、ngen.exe を強制終了したりするのは一時的な対策に過ぎず、問題は解決しません。

マイクロソフトがなぜこのような問題をこれほど長い間放置できたのか、私には理解できません。今日は検索して初めて答えが見つかった日でした。

この問題に関する詳しい情報はこちらをご覧くださいhttps://aloiskraus.wordpress.com/2017/12/13/the-case-of-ngen-exe-needing-50-gb-of-memory/

答え3

これは私の場合はうまくいきました。オンラインで人々が言っ​​ていたことをすべて実行した後、ウイルススキャンを実行したところ、すぐに戻ってきました。.netframeworkという名前の.dllファイルの形のウイルスがありました。それはCPUマイニングウイルスであることがわかりました。これが役立つことを願っています。

関連情報