アップデート失敗で試すWindows Updateコンポーネントを手動でリセットするバッチファイル
目次
Windows Update Clientを最新にしてもアップデートに失敗するときはWindows Updateコンポーネントをリセットしてみてください。以下がそれを行うバッチファイルのソースとなります。Windows 10/8.1/8/7/Vistaで使えます。
実行は管理者として実行しないとエラーになります。 実行後は再起動して再度Windows Updateを行ってみてください。
バッチファイルのソース
@ echo off echo . echo ============================================== echo Windows Updateコンポーネントをリセットします。 echo ============================================== echo . rem 開始確認 set /p YORN= "開始しますか? (y or n):" if not '%YORN%' == 'y' ( echo "処理を中止します。" GOTO END ) rem WMICコマンドで取得したOS情報を変数に代入 FOR /F "tokens=*" %%A IN ( 'WMIC OS Get ServicePackMajorVersion^,BuildNumber^,Caption /Value ^| find "="' ) DO ( SET OS. %%A ) rem サービスの停止 net stop bits net stop wuauserv net stop appidsvc net stop cryptsvc rem Windows 10 の場合 echo %OS.Caption% | find "Windows 10" > NUL if %ERRORLEVEL% equ 0 ( net stop usosvc ) rem gmgr*.datファイルを削除 del "%ALLUSERSPROFILE%\Application Data\Microsoft\Network\Downloader\qmgr0.dat" del "%ALLUSERSPROFILE%\Application Data\Microsoft\Network\Downloader\qmgr1.dat" rem 初めて実行するときはスキップし、効果がないときに実行する部分 echo . echo 実行確認=========================================== echo 初めて実行する場合はスキップ(n)をおすすめします。 echo スキップして効果がないときに実行(y)してください。 echo =================================================== echo . set /p YORN2= "積極的モードで実行しますか? (y or n):" if '%YORN2%' == 'y' ( Ren %systemroot% \SoftwareDistribution SoftwareDistribution.old Ren %systemroot% \system32\catroot2 catroot2.old sc .exe sdset bits "D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;AU)(A;;CCLCSWRPWPDTLOCRRC;;;PU)" sc .exe sdset wuauserv "D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;AU)(A;;CCLCSWRPWPDTLOCRRC;;;PU)" ) rem BITS ファイルと Windows Update ファイルを登録 cd /d %windir% \system32 regsvr32.exe atl.dll /s regsvr32.exe urlmon.dll /s regsvr32.exe mshtml.dll /s regsvr32.exe shdocvw.dll /s regsvr32.exe browseui.dll /s regsvr32.exe jscript.dll /s regsvr32.exe vbscript.dll /s regsvr32.exe scrrun.dll /s regsvr32.exe msxml.dll /s regsvr32.exe msxml3.dll /s regsvr32.exe msxml6.dll /s regsvr32.exe actxprxy.dll /s regsvr32.exe softpub.dll /s regsvr32.exe wintrust.dll /s regsvr32.exe dssenh.dll /s regsvr32.exe rsaenh.dll /s regsvr32.exe gpkcsp.dll /s regsvr32.exe sccbase.dll /s regsvr32.exe slbcsp.dll /s regsvr32.exe cryptdlg.dll /s regsvr32.exe oleaut32.dll /s regsvr32.exe ole32.dll /s regsvr32.exe shell32.dll /s regsvr32.exe initpki.dll /s regsvr32.exe wuapi.dll /s regsvr32.exe wuaueng.dll /s regsvr32.exe wuaueng1.dll /s regsvr32.exe wucltui.dll /s regsvr32.exe wups.dll /s regsvr32.exe wups2.dll /s regsvr32.exe wuweb.dll /s regsvr32.exe qmgr.dll /s regsvr32.exe qmgrprxy.dll /s regsvr32.exe wucltux.dll /s regsvr32.exe muweb.dll /s regsvr32.exe wuwebv.dll /s rem WINSOCKをリセット netsh winsock reset netsh winhttp reset proxy rem サービスを開始 net start bits net start wuauserv net start appidsvc net start cryptsvc rem Windows 10 の場合 echo %OS.Caption% | find "Windows 10" > NUL if %ERRORLEVEL% equ 0 ( net start usosvc ) rem Windows Vista の場合 echo %OS.Caption% | find "Windows Vista" > NUL if %ERRORLEVEL% equ 0 ( bitsadmin.exe /reset /allusers ) echo . echo 処理が完了しました。あとで再起動してください。 echo . pause :END |
バッチファイルのダウンロード
上記のバッチファイルは以下よりダウンロードできます。管理者権限で実行してください。
参考
リセット後のWindowsアップデートは時間がかかる
Windows Updateコンポーネントのリセットを行うと、後は以下のことに注意してください。
- 今までのWindows Updateの更新履歴はすべて消えます。
- 初回の更新ファイルの確認が重くて時間がかかります。
バッチファイルのソース(その2)
もっとコンパクトなソースも見つけました。Windows 10/8.1/8/7で使えます。
@ echo off rem WMICコマンドで取得したOS情報を変数に代入 FOR /F "tokens=*" %%A IN ( 'WMIC OS Get ServicePackMajorVersion^,BuildNumber^,Caption /Value ^| find "="' ) DO ( SET OS. %%A ) rem Windows 10 の場合 echo %OS.Caption% | find "Windows 10" > NUL if %ERRORLEVEL% equ 0 ( net stop usosvc net stop dosvc ) net stop wuauserv net stop cryptSvc net stop bits net stop msiserver ren %systemroot% \SoftwareDistribution SoftwareDistribution.old ren %systemroot% \System32\catroot2 catroot2.old del "%ALLUSERSPROFILE%\Microsoft/Network\Downloader\qmgr0.dat" del "%ALLUSERSPROFILE%\Microsoft/Network\Downloader\qmgr1.dat" net start msiserver net start bits net start cryptSvc net start wuauserv rem Windows 10 の場合 echo %OS.Caption% | find "Windows 10" > NUL if %ERRORLEVEL% equ 0 ( net start usosvc net start dosvc ) pause exit |
バックアップ(*.old)を削除するコマンド
Windows Updateが正常にできるようになったら、上記のバッチで作成されたバックアップファイルは不要になるので削除します。以下は削除を簡単に行うためのコマンドです。
rmdir %systemroot% \softwaredistribution.old /q /s rmdir %systemroot% \System32\catroot2.old /q /s |
参考
Windows10用のバッチファイルのソース(その3)
Windows10限定であれば以下のソースでいけるみたいです。
net stop usosvc net stop dosvc net stop wuauserv net stop bits move %SystemRoot% \SoftwareDistribution %SystemRoot% \SoftwareDistribution.old del %ALLUSERSPROFILE% \Microsoft\Network\Downloader\qmgr0.dat del %ALLUSERSPROFILE% \Microsoft\Network\Downloader\qmgr1.dat net start bits net start wuauserv net start dosvc net start usosvc %SystemRoot% \system32\usoclient.exe StartScan |
参考
その他の方法
Windows Updateの一時ファイルを削除する方法
システム更新準備ツールを使用する方法
ディスククリーンアップで[Windows Updateのクリーンアップ]を行う方法
またそれをコマンドおよびバッチファイルで実行する方法もありました。