M HYPE SPLASH
// general

Batch file that runs cmd.exe, several commands one after the other

By Emma Terry

I'd like to make a batch file that:

  1. Opens the Command Prompt
  2. Mounts an .ISO
  3. Then runs:

    DISM /Online /Cleanup-Image /StartComponentCleanup
    DISM /Online /Cleanup-Image /AnalyzeComponentStore
    DISM /Online /Cleanup-Image /RestoreHealth /source:WIM:F:\Sources\Install.wim:1 /LimitAccess
    SFC /SCANNOW

How would I go about doing that? I already know how to create a .bat file and how to run it as admin. Thanks in advance for your answers!

2

1 Answer

There are two options how to mount ISO using script: to use powershell Mount-DiskImage commandlet (follow the link to see the ready how-to answer) or to use an external utility PowerISO in a batch file. Due to your question was about batch file here is an example with PowerISO:

piso mount d:\test.iso F:
DISM /Online /Cleanup-Image /StartComponentCleanup
DISM /Online /Cleanup-Image /AnalyzeComponentStore
DISM /Online /Cleanup-Image /RestoreHealth /source:WIM:F:\Sources\Install.wim:1 /LimitAccess
SFC /SCANNOW

You don't need an extra command to open command prompt - when running batch file it will start command prompt by itself. In this example you mount file test.iso located on D: drive to a virtual drive F:

You will also need to specify the real path to piso.exe in the batch file.

3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy