Created
April 10, 2017 18:30
-
-
Save sean-m/c3e3c14f5ff5d944897748d679164f08 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
echo. | |
echo "Stop services" | |
::pause | |
sc stop msiserver | |
sc stop TrustedInstaller | |
echo. | |
echo "Disable services" | |
::pause | |
sc config msiserver start= disabled | |
sc config TrustedInstaller start= disabled | |
echo. | |
echo "Backup acls" | |
::pause | |
icacls "%WINDIR%\WinSxS" /save "%WINDIR%\WinSxS.acl" /t | |
echo. | |
echo "Take ownership" | |
::pause | |
takeown /f "%WINDIR%\WinSxS" /r | |
echo. | |
echo "Grant rights to WinSxS" | |
::pause | |
icacls "%WINDIR%\WinSxS" /grant "%USERDOMAIN%\%USERNAME%":(F) /t | |
echo. | |
echo "Compress" | |
::pause | |
compact /c /s:"%WINDIR%\WinSxS" /i | |
echo. | |
echo "Restore ownserhip" | |
::pause | |
icacls "%WINDIR%\WinSxS" /setowner "NT SERVICE\TrustedInstaller" /t | |
echo. | |
echo "Restore ACLs" | |
::pause | |
icacls "%WINDIR%" /restore "%WINDIR%\WinSxS.acl" | |
echo. | |
echo "Delete ACL backup" | |
::pause | |
del "%WINDIR%\WinSxS.acl" | |
echo. | |
echo "Restore service configuration" | |
::pause | |
sc config msiserver start= demand | |
sc config TrustedInstaller start= demand | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment