WindowsUpdateで配信されたファイルを削除してDISKの空き領域を増加させる

 Windows標準機能の「ディスクのクリーンアップ」・「システムファイルのクリーンアップ」で、Windows Updateのクリーンアップを実行後も、Windows Updateにより配信されたファイルがDISK内に溜まっていることがあるようです。
 具体的なディレクトリは C:\WINDOWS\SoftwareDistribution\Download\ になるのですが、このディレクトリはWindows Update Agentが管理しているため、基本的にはユーザが直接手を触れるべきではないようです。

 検索してみると、このディレクトリを消す記事は大量に出てきます。とは言え、Microsoftのサポートドキュメント等では同様の案内は見つからず、どうやら一部のユーザが勝手にやってるだけのようです。
 ですが、フォーラム内でMicrosoft社員のLizette Ags氏が、以下のように記載しています。

The folders that you've mentioned are where the automatic updates stored. We suggest that you check your Windows settings if there are cumulative updates that need to be installed. Once all updates are installed, you'll have the option to delete those folders.

Note: Once you delete the folders, Windows Update will take longer than usual to detect and update your computer because the WUAgent must check and re-create the Datastore information. The next time you install new Windows Updates, it will take time to process and complete as the system of your computer will check the logs that supposed to be saved on those folders.

software distribution files that occupy a lot of space, can they be - Microsoft Community
 気になるところだけ適当に意訳すると、「全てのアップデートがインストール済みならそのディレクトリを消すことも選択肢の一つ。」「そのディレクトリを消去すると、Windows Update Agentがデータストア情報を再作成する必要があるのでWindows Updateが普段より長時間かかるようになるだろう。」と言った感じの事が書いてあります。ので、削除しても重大な問題は無さそうです。

 というわけで、実施してみました。
<警告> Microsoftが公式に推奨している手段ではありません。実施する場合は自己責任となります。
 

手順

Windows Updateを実行

 インストール待ちや再起動待ち状態ではなく、「最新の状態です」表示であることを確認する。
 

Windows Updateサービスを停止

 巷の情報では、事前にWindows Updateサービス(wuauserv)を停止させろと書いてありますが、私の環境では実行中ではありませんでした。
 services.mscを実行してGUIから停止させてもいいですし、コマンドで停止させる場合は以下の通り。

> net stop wuauserv

 

削除

 現在のC:\WINDOWS\SoftwareDistribution\Downloadの使用量を確認後、当該ディレクトリ内を全削除します。

> wsl du -h -d 0 `wslpath "C:\\WINDOWS\\SoftwareDistribution\\Download"`
2.0G    /mnt/c/Windows/SoftwareDistribution/Download

> del /s /q C:\WINDOWS\SoftwareDistribution\Download\*

> wsl du -h -d 0 `wslpath "C:\\WINDOWS\\SoftwareDistribution\\Download"`
0       /mnt/c/Windows/SoftwareDistribution/Download

 約2GB消費されていたのが削除できました。
 

Windows Updateサービスを開始

 停止させたWindows Updateサービスを開始します。私の環境のようにもともとWindows Updateサービスが実行中でなければここであらためて開始する必要はありません。
 停止時と同様、services.mscからGUIで開始させてもいいですし、コマンドで開始させる場合は以下の通り。

> net start wuauserv

 

Windows Updateを実行

 Windows Updateに問題が起きていないことを確認するため、GUIからWindows Updateを実行します。

 今回はたまたまWindows Defenderの定義ファイル更新がありました。アップデート完了後、念のため先のディレクトリの使用量を確認すると以下のようになっていました。

> wsl du -h -d 0 `wslpath "C:\\WINDOWS\\SoftwareDistribution\\Download"`
7.4M    /mnt/c/Windows/SoftwareDistribution/Download

 アップデート完了後に即時消去されるのではなく、こういった感じで溜まってくようですね。
 



以上。