Search code examples
batch-filepipedism

piping answer to DISM in batch file


I want to install UWF feature through DISM in Windows 10. This works! However, I need to do this several times so I have the DISM command in a batch file. When the DISM command succeeds, it asks if I want to reboot. How can I feed (pipe) an answer? The following does NOT work:

echo n | DISM /online /Enable-Feature...

How can I accomplish this so that reboot question is automatically answered with n (No)?

Thanks


Solution

  • You can run DISM /? to show the documentation page for Deployment Image Servicing and Management tool (DISM).

    You'll see a section in the documentation titled DISM OPTIONS:

    DISM OPTIONS:
    
      /English                - Displays command line output in English.
      /Format                 - Specifies the report output format.
      /WinDir                 - Specifies the path to the Windows directory.
      /SysDriveDir            - Specifies the path to the system-loader file named
                                BootMgr.
      /LogPath                - Specifies the logfile path.
      /LogLevel               - Specifies the output level shown in the log (1-4).
      /NoRestart              - Suppresses automatic reboots and reboot prompts.
      /Quiet                  - Suppresses all output except for error messages.
      /ScratchDir             - Specifies the path to a scratch directory.
    

    This section details the /NoRestart option which is what you are looking for.

    You can apply it to your script like the following...

    DISM /online /Enable-Feature... /NoRestart