如何消除 C:\Windows\Installer 中巨大的缓存 MSI 文件?

Ste*_*mul 6 installation windows-installer disk-space-utilization msi uninstall

MSI 缓存文件夹( C:\Windows\Installer)的大小大幅增加,现在占用了我(域)计算机上的太多磁盘空间。这个文件夹可以消除或缩小吗?

同样的问题适用于:

  • C:\WINDOWS\WinSxS( %SystemRoot%\WinSxS)
  • C:\System32\DriverStore( %SystemRoot%\System32\DriverStore)

Ste*_*mul 11

概括

%SystemRoot%\Installer绝对不能干预目录及其内容。几乎总是会导致无法使用的系统。同去的WinSxS文件驱动程序库GAC

使用管理安装(请略读链接的答案)是减少%SystemRoot%\Installer文件夹大小以备将来部署的通用措施。通常用于企业部署。Essentially a file extraction of installation source that you put on a network share.

  • Administrative installs can drastically reduce the size of the local cache folder
  • Must be done per package,和你need a stable, always on network share(或一个stable local path / drive)。
  • 见底部"Administrative Installation"

一般磁盘空间提示

真正的问题是磁盘空间-SSD drives仍然太小,不舒服。下面是一些建议的过程,您可以使用它以更安全的方式重新获得空间。


原答案和长答案

以下是从这个原始而凌乱的答案中总结的基本/最有效的选项:琐事与技巧:释放系统驱动器上磁盘空间的明显方法(长)。

微软关于空间回收的文章:释放 Windows 10 中的驱动器空间


快车:紧急 5 分钟空间开垦

  1. 存储:插入USB 驱动器(如果您想要永久连接,请低调)或SD 卡。将您的内容Downloads,并Largest Media folders在那里。使用USB 3.X port!(蓝色/红色/蓝绿色)。
  2. Mongers Sweep:在 Windows 资源管理器中,选择"Users folder"(C:\Users),按下F3并选择"Size: Gigantic"(或非常大)。如果发现它们,请将它们移开 - 小心:
    • 通常ISOs, Virtuals, Movie files,etc...
    • 小心:Outlook PST filesDatabase files
    • 不用管:所有*.SYS文件!
    • 避免source code foldersvirtual disks(仅移动整个文件夹)!
    • 简而言之: Move only files you know are safe to move!
  3. Zap 可重新下载的文件?(很多大文件很容易被重新获取)
    • iTunes?, ISOs?, Installers(在Downloads)
    • Zap clouded files? (本地缓存)

下面还有许多其他选项。只是我自己使用的 5 分钟紧急程序(琐碎选项)。

显然清空回收站:-)。还可以快速卸载未使用的大型软件包。

并检查 C:\ 的根目录是否有虚拟和类似用途。不过,大多数大文件应该在配置文件层次结构中。


回收光盘空间 - 实用的选择

推荐的实际磁盘空间回收快速选项:

薄型 USB 和 SD 卡

  • 将军Removables & Disc Space Visualization

    • low-profile USB drive和/或添加SD-Card到您的笔记本电脑以获得“永久”,额外的存储空间以将大文件移动到。一般不高速,相应使用。注意!我发现低调的 USB 驱动器在负载下可能会运行得有点热。恕我直言,不适用于大量连续使用。
    • Find Space Hogshttps://en.wikipedia.org/wiki/WinDirStat。磁盘空间消耗的可视化工具。可能在非 SSD 磁盘上运行缓慢。显示什么会吃掉您的光盘。
  • 选项0Clouding。明显地。OneDriveDropboxGoogle Drive,等...

  • 选项2Microsoft's Disk Cleanup Tool。清除 Windows 更新文件等。

    • Windows Key+ 点击R,输入cleanmgr.exe并按下Enter
    • 选择系统驱动器并按 OK
    • 现在单击Clean up System Files然后选择系统驱动器并按OK
  • UPDATE Oct.2018: Microsoft has added the "Downloads" folder as a cleanup option! This is pure lunacy, DO NOT ENABLE! It deletes the whole downloads folder without question.

And one more update:

Note: In recent Windows 10 version the cleanmgr.exe tool has been deprecated and replaced with the new Windows 10 settings app. Type: ms-settings:storagesense in the start dialog to open the new GUI. The start dialog opens with: Windows Key + Tap R.

  • Option 7: Clean out Downloads folder (all users).
    • Move files to USB / SD / other partition.
    • Change default Downloads location: Right Click Folder => Properties => Location.
    • One shared location for all users - if applicable?
  • Option 18: Compression (selective folders?). In Folder Properties. May be ultra slow for old disks.
  • Option 19: Uninstall unnecessary software. Run appwiz.cpl from Windows Key + Tap R

High risk option: Delete outdated and obsolete recovery partition(s) and create a usable partition in its place to keep data on.

Runners-Up: Option 4: Administrative Installation is presented below. Maybe also check Option 3: (CCleaner) (not without risk). And a final mention: you can turn off system restore as well (particularly for virtuals). Not listed in linked answer (max lenght).


Scavenging / Putting WinSxS on a Diet

The WinSxS folder - Win32 side-by-side assembly store is full of hard links (several shortcuts to the same "physical" file) and often obsolete versions that can never be used (superseded by policy and updates). You can run "Scavenging" - garbage collection for side-by-side Win32 assemblies.

"Find actual size" command that is available since Win 8.1 (from elevated command prompt):

Dism.exe /Online /Cleanup-Image /AnalyzeComponentStore  
Run Code Online (Sandbox Code Playgroud)

This goes beyond all the hard links in there and finds the actual size of the WinSxS folder - and whether it should be cleaned up.

Run "Scavenging" (from elevated command prompt):

 Dism.exe /online /Cleanup-Image /StartComponentCleanup
Run Code Online (Sandbox Code Playgroud)

Microsoft's Disk Cleanup Tool: cleanmgr.exe seems to kick off "scavenging" sometimes. And there is a scheduled task (Win8 up) - kicking off cleanup. Slightly different from running the command. 30 days grace period before purging, and some timeout issues (ends after 1 hour, regardless).


Superuser: Why does the /winsxs folder grow so large, and can it be made smaller?


Administrative Installation

You can't safely delete these files, they are there to facilitate uninstall, modify and repair operations for the installed product. You can, however, greatly reduce the size of the cached MSI files by running an administrative installation (essentially a file extraction) of the MSI before installing it. Follow link above for description - you should put these extracted files on a network share.

The cached MSI files used to be small because they were stripped of their internal CAB files. However, starting with Windows 7 (MSI version 5) the MSI files are now cached full size to avoid breaking the file signature that affects the UAC prompt on setup launch (a known Vista problem). This may cause a tremendous increase in disk space consumption (several gigabytes for some systems).

Running admin install will extract the files from the CAB files embedded in the MSI, adjust the media layout in the Media table in the new MSI so that running it will use the extracted, external source files instead of internal CABs. The new and smaller MSI file used for installation is then cached on the system. This can save several gigabytes of disk space, depending on what installers you use, how many you have to install, how big they are, etc... Keep in mind that you must deal with the UAC prompt issue described above when using admin images since the extracted MSI is (normally) no longer signed, but from a reputable source (your own extraction).

The extracted files and the associated MSI file should be put on a network installation point along with all other installers to ensure files are available for repair operations. This is how most large corporations deal with installation anyway. Then there is no need for embedded CAB files in the cached MSI at all. SCCM and other deployment systems may also have other ways to ensure files are available for repair operations.

Some further links:

  • “你不能删除这些文件”->你*不应该*删除这些文件,因为这样做会破坏东西。 (2认同)