Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Application Programming › Batch Remove Uninstalled WinSxS Components/Features
New Posts  All Forums:Forum Nav:

Batch Remove Uninstalled WinSxS Components/Features

post #1 of 3
Thread Starter 
http://www.howtogeek.com/174705/how-to-reduce-the-size-of-your-winsxs-folder-on-windows-7-or-8/
You can remove Windows features with DISM using commands like:
Code:
DISM.exe /Online /Disable-Feature /featurename:TelnetServer /Remove

But as you can see, removing each disabled feature's installer one at a time would be extremely time consuming. (Feature list and states below).

The purpose of this thread is to find the answer for one simple question:

Is there a command or other way to remove all disabled packages automatically?

NOTE: This is a good thing to do. If you want an uninstalled feature after it has been removed from your WinSxS folder windows will simply ask to download it. No harm done.
Code:
Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

C:\Windows\system32>DISM.exe /Online /English /Get-Features /Format:Table

Deployment Image Servicing and Management tool
Version: 6.3.9600.17031

Image Version: 6.3.9600.17031

Features listing for package : Microsoft-Windows-Foundation-Package~31bf3856ad36
4e35~amd64~~6.3.9600.16384


----------------------------------------------------- | ------------------------
-----
Feature Name                                          | State

----------------------------------------------------- | ------------------------
-----
Microsoft-Hyper-V-All                                 | Disabled with Payload Re
moved
Microsoft-Hyper-V-Tools-All                           | Disabled with Payload Re
moved
Microsoft-Hyper-V                                     | Disabled with Payload Re
moved
Microsoft-Hyper-V-Management-Clients                  | Disabled with Payload Re
moved
Microsoft-Hyper-V-Management-PowerShell               | Disabled with Payload Re
moved
Printing-Foundation-Features                          | Enabled

Printing-Foundation-LPRPortMonitor                    | Disabled

Printing-Foundation-LPDPrintService                   | Disabled

Printing-Foundation-InternetPrinting-Client           | Enabled

FaxServicesClientPackage                              | Enabled

ScanManagementConsole                                 | Disabled with Payload Re
moved
LegacyComponents                                      | Disabled

DirectPlay                                            | Disabled

SimpleTCP                                             | Disabled

SNMP                                                  | Disabled

WMISnmpProvider                                       | Disabled

Windows-Defender-Default-Definitions                  | Disabled

Windows-Identity-Foundation                           | Disabled

MicrosoftWindowsPowerShellV2Root                      | Enabled

MicrosoftWindowsPowerShellV2                          | Enabled

DirectoryServices-ADAM-Client                         | Disabled

Internet-Explorer-Optional-amd64                      | Disabled with Payload Re
moved
NetFx3                                                | Enabled

IIS-WebServerRole                                     | Disabled

IIS-WebServer                                         | Disabled

IIS-CommonHttpFeatures                                | Disabled

IIS-HttpErrors                                        | Disabled

IIS-HttpRedirect                                      | Disabled

IIS-ApplicationDevelopment                            | Disabled

IIS-NetFxExtensibility                                | Disabled

IIS-NetFxExtensibility45                              | Disabled

IIS-HealthAndDiagnostics                              | Disabled

IIS-HttpLogging                                       | Disabled

IIS-LoggingLibraries                                  | Disabled

IIS-RequestMonitor                                    | Disabled

IIS-HttpTracing                                       | Disabled

IIS-Security                                          | Disabled

IIS-URLAuthorization                                  | Disabled

IIS-RequestFiltering                                  | Disabled

IIS-IPSecurity                                        | Disabled

IIS-Performance                                       | Disabled

IIS-HttpCompressionDynamic                            | Disabled

IIS-WebServerManagementTools                          | Disabled

IIS-ManagementScriptingTools                          | Disabled

IIS-IIS6ManagementCompatibility                       | Disabled

IIS-Metabase                                          | Disabled

WAS-WindowsActivationService                          | Disabled

WAS-ProcessModel                                      | Disabled

WAS-NetFxEnvironment                                  | Disabled

WAS-ConfigurationAPI                                  | Disabled

IIS-HostableWebCore                                   | Disabled

IIS-CertProvider                                      | Disabled

IIS-WindowsAuthentication                             | Disabled

IIS-DigestAuthentication                              | Disabled

IIS-ClientCertificateMappingAuthentication            | Disabled

IIS-IISCertificateMappingAuthentication               | Disabled

IIS-ODBCLogging                                       | Disabled

IIS-StaticContent                                     | Disabled

IIS-DefaultDocument                                   | Disabled

IIS-DirectoryBrowsing                                 | Disabled

IIS-WebDAV                                            | Disabled

IIS-WebSockets                                        | Disabled

IIS-ApplicationInit                                   | Disabled

IIS-ASPNET                                            | Disabled

IIS-ASPNET45                                          | Disabled

IIS-ASP                                               | Disabled

IIS-CGI                                               | Disabled

IIS-ISAPIExtensions                                   | Disabled

IIS-ISAPIFilter                                       | Disabled

IIS-ServerSideIncludes                                | Disabled

IIS-CustomLogging                                     | Disabled

IIS-BasicAuthentication                               | Disabled

IIS-HttpCompressionStatic                             | Disabled

IIS-ManagementConsole                                 | Disabled

IIS-ManagementService                                 | Disabled

IIS-WMICompatibility                                  | Disabled

IIS-LegacyScripts                                     | Disabled

IIS-LegacySnapIn                                      | Disabled

IIS-FTPServer                                         | Disabled

IIS-FTPSvc                                            | Disabled

IIS-FTPExtensibility                                  | Disabled

MSMQ-Container                                        | Disabled

MSMQ-Server                                           | Disabled

MSMQ-Triggers                                         | Disabled

MSMQ-ADIntegration                                    | Disabled

MSMQ-HTTP                                             | Disabled

MSMQ-Multicast                                        | Disabled

MSMQ-DCOMProxy                                        | Disabled

WCF-Services45                                        | Enabled

WCF-HTTP-Activation45                                 | Disabled

WCF-TCP-Activation45                                  | Disabled

WCF-Pipe-Activation45                                 | Disabled

WCF-MSMQ-Activation45                                 | Disabled

WCF-TCP-PortSharing45                                 | Enabled

WCF-HTTP-Activation                                   | Disabled

WCF-NonHTTP-Activation                                | Disabled

NetFx4-AdvSrvs                                        | Enabled

NetFx4Extended-ASPNET45                               | Disabled

Microsoft-Windows-MobilePC-Client-Premium-Package-net | Disabled

Microsoft-Windows-MobilePC-LocationProvider-INF       | Disabled

Printing-XPSServices-Features                         | Disabled

RasCMAK                                               | Disabled

RasRip                                                | Disabled with Payload Re
moved
MSRDC-Infrastructure                                  | Enabled

SearchEngine-Client-Package                           | Enabled

TelnetClient                                          | Disabled

TelnetServer                                          | Disabled with Payload Re
moved
TFTP                                                  | Disabled

TIFFIFilter                                           | Disabled

Xps-Foundation-Xps-Viewer                             | Disabled

WorkFolders-Client                                    | Disabled

SMB1Protocol                                          | Disabled

MediaPlayback                                         | Enabled

WindowsMediaPlayer                                    | Enabled


The operation completed successfully.

C:\Windows\system32>

Edited by cookieboyeli - 9/19/15 at 9:16pm
post #2 of 3
Thread Starter 
Bump
post #3 of 3
Thread Starter 
I found some information.
https://stackoverflow.com/questions/26668033/automatically-remove-windows-features-which-are-already-disabled-using-cmd-and-d

Using this in a batch file should do what I want!
Code:
for /f %%a in ('dism /online /get-features /format:table ^|find "| Disabled"') do (dism /online /disable-feature:%%a /remove)

However, I did run into a little snag. I put it in an elevated command prompt thinking it would work the same, but instead I got this error:
Code:
%%A was unexpected at this time

A little Googling revealed this: In batch use %%i, whereas in command line use %i. (Sorry, tagging as code was messing up formatting).

Note: there are two places where one must be removed. So above is the command for .bat/.cmd. This is what to use if you are running it directly from command prompt as admin:
Code:
for /f %a in ('dism /online /get-features /format:table ^|find "| Disabled"') do (dism /online /disable-feature:%a /remove)

thumb.gif

Unfortunately it didn't save NEARLY as much space as I was expecting. I think it saved something like 50MB? Haha oh well, it was fun! tongue.gif

Mission Success!: Spoiler! (Click to show)
Code:
Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

C:\Windows\system32>DISM.exe /Online /English /Get-Features /Format:Table

Deployment Image Servicing and Management tool
Version: 6.3.9600.17031

Image Version: 6.3.9600.17031

Features listing for package : Microsoft-Windows-Foundation-Package~31bf3856ad36
4e35~amd64~~6.3.9600.16384


----------------------------------------------------- | ------------------------
-----
Feature Name                                          | State

----------------------------------------------------- | ------------------------
-----
Microsoft-Hyper-V-All                                 | Disabled with Payload Re
moved
Microsoft-Hyper-V-Tools-All                           | Disabled with Payload Re
moved
Microsoft-Hyper-V                                     | Disabled with Payload Re
moved
Microsoft-Hyper-V-Management-Clients                  | Disabled with Payload Re
moved
Microsoft-Hyper-V-Management-PowerShell               | Disabled with Payload Re
moved
Printing-Foundation-Features                          | Enabled

Printing-Foundation-LPRPortMonitor                    | Disabled with Payload Re
moved
Printing-Foundation-LPDPrintService                   | Disabled with Payload Re
moved
Printing-Foundation-InternetPrinting-Client           | Enabled

FaxServicesClientPackage                              | Enabled

ScanManagementConsole                                 | Disabled with Payload Re
moved
LegacyComponents                                      | Disabled with Payload Re
moved
DirectPlay                                            | Disabled with Payload Re
moved
SimpleTCP                                             | Disabled with Payload Re
moved
SNMP                                                  | Disabled with Payload Re
moved
WMISnmpProvider                                       | Disabled with Payload Re
moved
Windows-Defender-Default-Definitions                  | Disabled

Windows-Identity-Foundation                           | Disabled with Payload Re
moved
MicrosoftWindowsPowerShellV2Root                      | Enabled

MicrosoftWindowsPowerShellV2                          | Enabled

DirectoryServices-ADAM-Client                         | Disabled with Payload Re
moved
Internet-Explorer-Optional-amd64                      | Disabled with Payload Re
moved
NetFx3                                                | Enabled

IIS-WebServerRole                                     | Disabled with Payload Re
moved
IIS-WebServer                                         | Disabled with Payload Re
moved
IIS-CommonHttpFeatures                                | Disabled with Payload Re
moved
IIS-HttpErrors                                        | Disabled with Payload Re
moved
IIS-HttpRedirect                                      | Disabled with Payload Re
moved
IIS-ApplicationDevelopment                            | Disabled with Payload Re
moved
IIS-NetFxExtensibility                                | Disabled with Payload Re
moved
IIS-NetFxExtensibility45                              | Disabled with Payload Re
moved
IIS-HealthAndDiagnostics                              | Disabled with Payload Re
moved
IIS-HttpLogging                                       | Disabled with Payload Re
moved
IIS-LoggingLibraries                                  | Disabled with Payload Re
moved
IIS-RequestMonitor                                    | Disabled with Payload Re
moved
IIS-HttpTracing                                       | Disabled with Payload Re
moved
IIS-Security                                          | Disabled with Payload Re
moved
IIS-URLAuthorization                                  | Disabled with Payload Re
moved
IIS-RequestFiltering                                  | Disabled with Payload Re
moved
IIS-IPSecurity                                        | Disabled with Payload Re
moved
IIS-Performance                                       | Disabled with Payload Re
moved
IIS-HttpCompressionDynamic                            | Disabled with Payload Re
moved
IIS-WebServerManagementTools                          | Disabled with Payload Re
moved
IIS-ManagementScriptingTools                          | Disabled with Payload Re
moved
IIS-IIS6ManagementCompatibility                       | Disabled with Payload Re
moved
IIS-Metabase                                          | Disabled with Payload Re
moved
WAS-WindowsActivationService                          | Disabled with Payload Re
moved
WAS-ProcessModel                                      | Disabled with Payload Re
moved
WAS-NetFxEnvironment                                  | Disabled with Payload Re
moved
WAS-ConfigurationAPI                                  | Disabled with Payload Re
moved
IIS-HostableWebCore                                   | Disabled with Payload Re
moved
IIS-CertProvider                                      | Disabled with Payload Re
moved
IIS-WindowsAuthentication                             | Disabled with Payload Re
moved
IIS-DigestAuthentication                              | Disabled with Payload Re
moved
IIS-ClientCertificateMappingAuthentication            | Disabled with Payload Re
moved
IIS-IISCertificateMappingAuthentication               | Disabled with Payload Re
moved
IIS-ODBCLogging                                       | Disabled with Payload Re
moved
IIS-StaticContent                                     | Disabled with Payload Re
moved
IIS-DefaultDocument                                   | Disabled with Payload Re
moved
IIS-DirectoryBrowsing                                 | Disabled with Payload Re
moved
IIS-WebDAV                                            | Disabled with Payload Re
moved
IIS-WebSockets                                        | Disabled with Payload Re
moved
IIS-ApplicationInit                                   | Disabled with Payload Re
moved
IIS-ASPNET                                            | Disabled with Payload Re
moved
IIS-ASPNET45                                          | Disabled with Payload Re
moved
IIS-ASP                                               | Disabled with Payload Re
moved
IIS-CGI                                               | Disabled with Payload Re
moved
IIS-ISAPIExtensions                                   | Disabled with Payload Re
moved
IIS-ISAPIFilter                                       | Disabled with Payload Re
moved
IIS-ServerSideIncludes                                | Disabled with Payload Re
moved
IIS-CustomLogging                                     | Disabled with Payload Re
moved
IIS-BasicAuthentication                               | Disabled with Payload Re
moved
IIS-HttpCompressionStatic                             | Disabled with Payload Re
moved
IIS-ManagementConsole                                 | Disabled with Payload Re
moved
IIS-ManagementService                                 | Disabled with Payload Re
moved
IIS-WMICompatibility                                  | Disabled with Payload Re
moved
IIS-LegacyScripts                                     | Disabled with Payload Re
moved
IIS-LegacySnapIn                                      | Disabled with Payload Re
moved
IIS-FTPServer                                         | Disabled with Payload Re
moved
IIS-FTPSvc                                            | Disabled with Payload Re
moved
IIS-FTPExtensibility                                  | Disabled with Payload Re
moved
MSMQ-Container                                        | Disabled with Payload Re
moved
MSMQ-Server                                           | Disabled with Payload Re
moved
MSMQ-Triggers                                         | Disabled with Payload Re
moved
MSMQ-ADIntegration                                    | Disabled with Payload Re
moved
MSMQ-HTTP                                             | Disabled with Payload Re
moved
MSMQ-Multicast                                        | Disabled with Payload Re
moved
MSMQ-DCOMProxy                                        | Disabled with Payload Re
moved
WCF-Services45                                        | Enabled

WCF-HTTP-Activation45                                 | Disabled with Payload Re
moved
WCF-TCP-Activation45                                  | Disabled with Payload Re
moved
WCF-Pipe-Activation45                                 | Disabled with Payload Re
moved
WCF-MSMQ-Activation45                                 | Disabled with Payload Re
moved
WCF-TCP-PortSharing45                                 | Enabled

WCF-HTTP-Activation                                   | Disabled with Payload Re
moved
WCF-NonHTTP-Activation                                | Disabled with Payload Re
moved
NetFx4-AdvSrvs                                        | Enabled

NetFx4Extended-ASPNET45                               | Disabled with Payload Re
moved
Microsoft-Windows-MobilePC-Client-Premium-Package-net | Disabled with Payload Re
moved
Microsoft-Windows-MobilePC-LocationProvider-INF       | Disabled with Payload Re
moved
Printing-XPSServices-Features                         | Disabled with Payload Re
moved
RasCMAK                                               | Disabled with Payload Re
moved
RasRip                                                | Disabled with Payload Re
moved
MSRDC-Infrastructure                                  | Enabled

SearchEngine-Client-Package                           | Enabled

TelnetClient                                          | Disabled with Payload Re
moved
TelnetServer                                          | Disabled with Payload Re
moved
TFTP                                                  | Disabled with Payload Re
moved
TIFFIFilter                                           | Disabled with Payload Re
moved
Xps-Foundation-Xps-Viewer                             | Disabled with Payload Re
moved
WorkFolders-Client                                    | Disabled with Payload Re
moved
SMB1Protocol                                          | Disabled with Payload Re
moved
MediaPlayback                                         | Enabled

WindowsMediaPlayer                                    | Enabled


The operation completed successfully.

C:\Windows\system32>

Here's a zipped cmd file for the lazy. (Like batch except newer)
RemoveUninstalledWinSxSComponents.zip 0k .zip file
Edited by cookieboyeli - 9/20/15 at 8:31am
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Application Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Application Programming › Batch Remove Uninstalled WinSxS Components/Features