Enable or Disable Windows Features Using DISM

The Deployment Image Servicing and Management (DISM) tool is a command-line tool that is used to modify Windows images. You can use DISM's Features commands to enable or disable Windows features directly from the command prompt, or by applying an answer file to the image. You can enable or disable Windows features offline on a WIM or VHD file, or online on a running operating system.

To mount an offline image for servicing

  1. Open a command prompt with administrator privileges.

  2. Use the /Get-ImageInfo option to retrieve the name or index number for the image that you want to modify. An index or name value is required for most operations that specify an image file.

    For example, at the command prompt type:

    Dism /Get-ImageInfo /ImageFile:C:\test\images\install.wim
    
  3. Mount the offline Windows image. For example, type:

    Dism /Mount-Image /ImageFile:C:\test\images\install.wim /Index:1 /MountDir:C:\test\offline
    

To find available Windows features in an image

  1. List all of the features available in the operating system. For example, type:

    Dism /online /Get-Features
    

    To service an offline image, specify the location of the mounted image directory. For example, type:

    Dism /Image:C:\test\offline /Get-Features
    

    You can add a > to the command to redirect the output of the command to a text file. For example, >featurelist.txt will output to a text file called featurelist.txt.

  2. Review the list of features to find the feature that you want to enable, disable, remove, or restore.

  3. Use /Get-FeatureInfo to list information about the specific feature you are interested in. For example, type:

    Dism /online /Get-FeatureInfo /FeatureName:TFTP
    

To enable Windows features

  1. Enable a specific feature in the image. You can use the /All argument to enable all of the parent features in the same command. For example:

    Dism /online /Enable-Feature /FeatureName:TFTP /All
    

    To service an offline image, specify the location of the mounted image directory. For example, type:

    Dism /Image:C:\test\offline /Enable-Feature /FeatureName:TFTP /All
    
  2. Optional: Get the status of the feature you have enabled. For example, type:

    Dism /online /Get-FeatureInfo /FeatureName:TFTP
    

    If the status is Enble Pending, you must boot the image in order to enable the feature entirely.

To restore removed Windows features

  1. Enable a specific feature in the image. If you do not specify a source, DISM will look in the default location specified by group policy for the required files needed to enable the feature For more information, see Configure a Windows Repair Source.

    If the files are not found in the default location, DISM will contact Windows Update (WU) for the required files, but a local repair source may also be required. You can use the /LimitAccess argument to prevent DISM from contacting WU.

    If you specify multiple /Source arguments, the files are gathered from the first location where they are found and the rest of the locations are ignored.

    For example, type:

    Dism /Online /Enable-Feature /FeatureName:TFTP /Source:Z:\sources\SxS /Source:C:\test\mount\windows /LimitAccess
    

    To service an offline image, specify the location of the mounted image directory. For example, type:

    Dism /Image:C:\test\offline /Enable-Feature /FeatureName:TFTP /Source:C:\test\mount\windows
    
  2. Optional: Get the status of the feature you have enabled. For example, type:

    Dism /online /Get-FeatureInfo /FeatureName:TFTP
    

    If the status is EnablePending, you must boot the image in order to enable the feature entirely.

To disable Windows features

  1. Disable a specific feature in the image. For example, type:

    Dism /online /Disable-Feature /FeatureName:TFTP
    

    To service an offline image, specify the location of the mounted image directory. For example, type:

    Dism /Image:C:\test\offline /Disable-Feature /FeatureName:TFTP
    
  2. Optional: Use DISM /GetFeatureInfo to get the status of the feature you have disabled. For example, type:

    Dism /online /Get-FeatureInfo /FeatureName:TFTP
    

    If the status is DisablePending, you must boot the image in order to disable the feature entirely.

To remove Windows features for on-demand installation

  1. Remove a specific feature in the image without removing the feature's manifest from the image. For more information, see Configure a Windows Repair Source.

    For example, type:

    Dism /online /Disable-Feature /FeatureName:TFTP /Remove
    

    To service an offline image, specify the location of the mounted image directory. For example, type:

    Dism /Image:C:\test\offline /Disable-Feature /FeatureName:TFTP /Remove
    
  2. Optional: Use DISM /GetFeatureInfo to get the status of the feature you have disabled. For example, type:

    Dism /online /Get-FeatureInfo /FeatureName:TFTP
    

    The status is Disabled. Beginning with Windows 10, the payload is not removed from Windows client editions in order to support Push-button reset. The payload is removed from Windows Server installations.

To enable or disable Windows features by using DISM and an answer file

  1. In Windows SIM, open an existing catalog by clicking Select a Windows Image on the File menu and specifying the catalog file type (.clg) in the drop-down list, or create a new catalog by clicking Create Catalog on the Tools menu.

  2. Expand the catalog in the Windows Image pane, and then expand Packages.

  3. Expand Foundation, and right-click Microsoft-Windows-Foundation-Package.

  4. Click Add to Answer File.

  5. Click Enabled or Disabled next to the features that you intend to enable or disable. Click the arrow to select the opposite choice.

    You might have to expand an item to see all its children. You must enable the parent if any one of its children are enabled.

    Note

    You can't restore or remove a Windows feature for features on demand with an unattended answer file.

  6. Click Tools on the main menu, and then click Validate Answer File.

  7. Correct any errors that appear in the Messages pane, and save the answer file.

  8. At the command prompt, type the following command to apply the unattended answer file to the image.

    Dism /online /Apply-Unattend:C:\test\answerfiles\myunattend.xml
    

    To service an offline image, specify the location of the mounted image directory. For example, type:

    Dism /Image:C:\test\offline /Apply-Unattend:C:\test\answerfiles\myunattend.xml
    

To commit changes on an offline image

  • Commit the changes and unmount the image. For example, type:

    Dism /Unmount-Image /MountDir:C:\test\offline /Commit
    

DISM - Deployment Image Servicing and Management Technical Reference for Windows

DISM Operating System Package Servicing Command-Line Options

DISM Unattended Servicing Command-Line Options

Configure a Windows Repair Source