-
-
Save andry81/38d215c1d3757c9844cb854c70362e17 to your computer and use it in GitHub Desktop.
WinSxS folder compression script
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 | |
net session >nul 2>&1 | |
IF %ERRORLEVEL% NEQ 0 GOTO ELEVATE | |
@GOTO ADMINTASKS | |
:ELEVATE | |
ECHO Elevated privileges are temporarily required to run script | |
cd /d %~dp0 | |
mshta "javascript: var shell = new ActiveXObject('Shell.Application'); shell.ShellExecute('%~nx0', '', '', 'runas', 1); close();" | |
EXIT /B | |
:ADMINTASKS | |
REM Script to compress WINSXS folder | |
REM thanks to http://woshub.com | |
sc stop msiserver | |
sc stop TrustedInstaller | |
sc config msiserver start= disabled | |
sc config TrustedInstaller start= disabled | |
icacls "%WINDIR%\WinSxS" /save "%WINDIR%\WinSxS_NTFS.acl" /t | |
takeown /f "%WINDIR%\WinSxS" /r | |
icacls "%WINDIR%\WinSxS" /grant "%USERDOMAIN%\%USERNAME%":(F) /t | |
compact /s:"%WINDIR%\WinSxS" /c /a /i * | |
icacls "%WINDIR%\WinSxS" /setowner "NT SERVICE\TrustedInstaller" /t | |
icacls "%WINDIR%" /restore "%WINDIR%\WinSxS_NTFS.acl" | |
sc config msiserver start= demand | |
sc config TrustedInstaller start= demand | |
PAUSE | |
@ECHO on |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment