压缩WinSxS文件夹命令
- 关闭其它在运行的程序,以管理员权限运行cmd,按顺序输入以下指令
- 停止并禁用Windows Installer和Windows Module Installer服务
sc stop msiserver
sc stop TrustedInstallersc config msiserver start= disabled
sc config TrustedInstaller start= disabled - 备份winsxs目录的ACLs(存取权限表,一会儿要还原的)
icacls "%WINDIR%WinSxS" /save "%WINDIR%WinSxS.acl" /t
- 获得WinSxS和其子目录的所有权
takeown /f "%WINDIR%WinSxS" /r
- 获得winsxs目录的所有权限
icacls "%WINDIR%WinSxS" /grant "%USERDOMAIN%%USERNAME%":(F) /t
- 压缩winsxs
compact /c /s:"%WINDIR%WinSxS" /i
- 把WinSxS和其子目录的所有权还给TrustedInstaller
icacls "%WINDIR%WinSxS" /setowner "NT SERVICETrustedInstaller" /t
- 还原winsxs目录的ACLs
icacls "%WINDIR%" /restore "%WINDIR%WinSxS.acl"
- 删掉备份的WinSxS.acl文件
del "%WINDIR%WinSxS.acl"
- 还原Windows Installer和Windows Module Installer服务为手动
sc config msiserver start= demand
sc config TrustedInstaller start= demand