piping answer to DISM in batch file

779 views Asked by At

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

2

There are 2 answers

0
Zam On BEST ANSWER

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
2
Zavulon On

Apparantly, there is an undocumented switch /norestart that just does what I want, I append it to the back of the command:

DISM /online /Enable-Feature... /norestart

I found this while checking the powershell version of the DISM command.