Compress WinSxS

This post is awesome. My Windows Seven virtual machine will finally fit on my usb key. I just copy the commands here for the record, and I group them so they can be easily copied to a .bat file.

REM Stop and disable Windows Installer and Windows Module Installer services
sc stop msiserver
sc stop TrustedInstaller

REM Backup ACLs for WinSxS folder (see icacls), so we can restore later
icacls "%WINDIR%\WinSxS" /save "%WINDIR%\WinSxS.acl" /t

REM Take ownership of WinSxS and subfolders
takeown /f "%WINDIR%\WinSxS" /r

REM Grant full rights on WinSxS to your user
icacls "%WINDIR%\WinSxS" /grant "%USERDOMAIN%\%USERNAME%":(F) /t

REM Compress WinSxS files and sub-folders
compact /s:"%WINDIR%\WinSxS" /c /a /i *

REM Restore ACLs for WinSxS folder we saved earlier.
icacls "%WINDIR%" /restore "%WINDIR%\WinSxS.acl"

REM Restore Windows Installer and Windows Module Installer services
sc config msiserver start= demand
sc config TrustedInstaller start= demand

#windows, #winsxs