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