Skip to main content

Script to Compress WinSXS

Compress WinSXS:

A Script to compress WinSXS folder resided in Windows directory.

if you are concern about the growing size of WinSXS folder taking so much of space then you can use this powershell script to reduce the size by compressing WinSXS folder data.
This script is very usefull in the case when you need to compress WinSXS folder in large number of Servers/Desktops environment.

#ā€”ā€”ā€”ā€”ā€”ā€”ā€”ā€”ā€”ā€”ā€”ā€”ā€”ā€”ā€“
# Script to compress WinSXS folder
try {
$winDir = ā€œ$($env:windir)ā€
$winSxSDir = ā€œ$winDir\WinSxSā€
$aclPath = ā€œ$winDir\WinSxS.aclā€
$serviceMSI = ā€œmsiserverā€
$serviceTI = ā€œTrustedInstallerā€

Stop-Service $serviceMSI
Stop-Service $serviceTI

Set-Service -Name $serviceMSI -StartupType Disabled
Set-Service -Name $serviceTI -StartupType Disabled

icacls.exe $winSxSDir /save $aclPath /t

takeown /f $winSxSDir /r

icacls $winSxSDir /grant ā€œ$($env:USERDOMAIN)\$($env:USERNAME)ā€:ā€(F)ā€ /t

compact /s:$winSxSDir /c /a /i *

icacls $winSxSDir /setowner ā€œNT SERVICE\TrustedInstallerā€ /t

icacls $winDir /restore $aclPath

Set-Service -Name $serviceMSI -StartupType Automatic
Set-Service -Name $serviceTI -StartupType Automatic
}
catch {
Write-Host -ForegroundColor Red $Error[0]
}
#ā€”ā€”ā€”ā€”ā€”ā€”ā€”ā€”ā€”ā€”ā€”ā€”ā€”ā€”ā€“

Note: Please note if server/desktop services (Msiserver & TrustedInstaller) are already stopped and in disabled state then this script will modify both services to automatic state.


Please find the script below you can also download the script from here.

https://www.dropbox.com/s/ojvavujuxpwt20m/Compress%20Winsxs.Bat?dl=0



Thanks for Reading my Blog

Enjoy Maddi

Comments

karteek varma saidā€¦
sc query msiserver
sc query TrustedInstaller

sc stop msiserver
sc stop TrustedInstaller

sc config msiserver start= disabled
sc config TrustedInstaller start= disabled

icacls "%WINDIR%\WinSxS" /save "%WINDIR%\WinSxS.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.acl"
del "%WINDIR%\WinSxS.acl"

sc config msiserver start= demand
sc config TrustedInstaller start= demand

sc start msiserver
sc start TrustedInstaller

Popular posts from this blog

ESM Log size is full - How to clear

                                            ESM log Size is full ---- How to Clear If your getting the below error in event viewer you can follow the below steps and solve it. Generally when we open Dell open manage console, suddenly we see that Hardware log status is showing critical and event logs are filling saying ESM log is full... We need to clear the ESM logs regularly before it reaches 100%. However please follow the below command and procedure before clearing the logs. Open Dell Manage console, go to logs tab. Then select ESM logs, you will see an export option. Export the logs and save it on local drive for future use. Now open command prompt and Runas administrator. Type omconfig system esmlog action=clear Done, ...

The system cannot log you on due to the following error: The RPC server is unavailable

IF your login to windows 2003 and your getting the below error then do the below steps and you can login to the PC. login to any server in the same subnet. open CMD in elevated permission open registry editor go to File---------->connect to network registry type the effected server name and open it go to the below location and create a new DWORD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server Create a new key selecting Dword and name it as IgnoreRegUserConfigErrors now double click it and give a value as 1. after that do the RDP and it will work.
  Remove "Open in new window" option from Windows Explorer right-click menu Hi Guys today we will see how to block the "Open in New Windows" tab in the file explorer menu. Please see the below screenshot which is showed below. Create the appropriate REG file(s) using this code and then run them: ADD 'Open in a New Window' Option Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\Folder\shell\opennewwindow] "MUIVerb"="@shell32.dll,-8517" "MultiSelectModel"="Document" "OnlyInBrowserWindow"="" "LaunchExplorerFlags"=dword:00000001 [HKEY_CLASSES_ROOT\Folder\shell\opennewwindow\command] "DelegateExecute"="{11dbb47c-a525-400b-9e80-a54615a090c0}" REMOVE 'Open in a New Window' Option Windows Registry Editor Version 5.00 [-HKEY_CLASSES_ROOT\Folder\shell\opennewwindow] "MUIVerb"="@shell32.dll,-8517" "MultiSelectModel"="Document...