Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @ECHO OFF
- SETLOCAL ENABLEEXTENSIONS
- COLOR 0A
- TITLE CONVERT AND MOUNT WIM OR ESD FILES
- :------------------------------------------------------------------------------------------------------------------------
- REM Created by: SlyFox1186
- REM Pastebin: https://pastebin.com/u/slyfox1186
- REM This batch script will convert a .esd file into a .wim or vice-versa
- REM then prompt the user to mount or unmount an offline image of windows
- REM thus allowing you to perform offline repairs in the event that the
- REM standard method of repairing a corrupted windows image has failed.
- REM You need to acquire a Windows .iso file and copy the 'install.esd|wim' file
- REM inside the sources folder into the same folder as this script.
- REM Save this using a .bat extension.
- :------------------------------------------------------------------------------------------------------------------------
- PUSHD "%~dp0"
- IF NOT "%1"=="MAX" START /MAX CMD /D /C %0 MAX & GOTO :EOF
- :------------------------------------------------------------------------------------------------------------------------
- ECHO Choose the input file to convert or skip this
- ECHO section and go straight to mount/unmount. & ECHO=
- ECHO [1] install.esd ^>^> install.wim
- ECHO [2] install.wim ^>^> install.esd
- ECHO [3] Skip and go to mount/unmount
- ECHO [4] Exit & ECHO=
- CHOICE /C 1234 /N & CLS
- IF ERRORLEVEL 4 GOTO :EOF
- IF ERRORLEVEL 3 GOTO MOUNT_THIS
- IF ERRORLEVEL 2 (
- SET FileIn=install.wim
- SET FileOut=install.esd
- ) ELSE (
- SET FileIn=install.esd
- SET FileOut=install.wim
- )
- :------------------------------------------------------------------------------------------------
- :GET_INDEX
- :------------------------------------------------------------------------------------------------
- DISM /Get-ImageInfo /ImageFile:%FileIn% & ECHO=
- SET Index=
- SET /P Index=Please select the index number that matches your Windows version: & CLS
- IF DEFINED Index (
- DISM /Export-Image /SourceImageFile:%FileIn% /SourceIndex:%Index% /DestinationImageFile:%FileOut% /Compress:Max /CheckIntegrity
- ) ELSE (
- ECHO You must enter one of the index numbers that match your Window's version! & ECHO=
- PAUSE
- CLS
- GOTO GET_INDEX
- )
- :------------------------------------------------------------------------------------------------
- :MOUNT_THIS
- :------------------------------------------------------------------------------------------------
- CLS
- ECHO %FileOut% has been created.
- TIMEOUT 4 >NUL
- ECHO=
- ECHO What next? & ECHO=
- ECHO [1] Mount
- ECHO [2] Unmount
- ECHO [3] Exit & ECHO=
- CHOICE /C 123 /N & CLS
- IF ERRORLEVEL 3 GOTO :EOF
- IF ERRORLEVEL 2 (
- DISM /Unmount-Image /MountDir:Mount /Discard
- GOTO :EOF
- )
- IF ERRORLEVEL 1 (
- IF NOT EXIST Mount MD Mount >NUL
- DISM /Mount-Image /ImageFile:%FileOut% /Index:1 /MountDir:Mount
- )
Advertisement
Add Comment
Please, Sign In to add comment