ESD <> WIM Conversion batch

Discussion in 'Scripting' started by liliactr, Apr 16, 2014.

  1. mukkelek

    mukkelek MDL Novice

    Nov 27, 2013
    1
    0
    0
    Damaged, not found.
     
  2. abbodi1406

    abbodi1406 MDL KB0000001

    Feb 19, 2011
    17,281
    91,248
    340
    updated links
     
  3. emparor

    emparor MDL Novice

    Sep 9, 2012
    46
    2
    0
    tryed it on the new win 10 build dont wanna work for me to extract the esd to wim
    :(
     
  4. abbodi1406

    abbodi1406 MDL KB0000001

    Feb 19, 2011
    17,281
    91,248
    340
  5. generalmx

    generalmx MDL Novice

    Apr 15, 2014
    34
    21
    0
    #25 generalmx, Nov 4, 2014
    Last edited by a moderator: Apr 20, 2017
    I've updated my own batch files to include pattern-matching in the wimfile name, such as grabbing only 64-bit copies from a WIM or ESD, for my experiments adding 8.1, 7, and Vista in one big ESD, but sized for <32GB flash drives. Here's wimtoesd.bat:
    Code:
    @echo off
    :: Safely extracts and converts a WIM to a ESD
    :: By Gen 11-2-2014
    ::
    :: Usage 1: wimtoesd.bat "path/to/file/file.wim"
    :: Extracts all indexes from file.wim to install.esd.
    ::
    :: Usage 2: wimtoesd.bat "path/to/file/file.wim" "Pattern"
    :: Extracts all indexes from file.wim to install.esd, only including names
    :: matching Pattern (simple word).
    ::
    :: Usage 2: wimtoesd.bat "path/to/file/file.wim" Start Stop
    :: Extracts indexes numbering from Start to Stop from file.wim to install.esd.
    ::
    :: Usage 3: wimtoesd.bat "path/to/file/file.wim" Start Stop "Pattern"
    :: Extracts indexes numbering from Start to Stop from file.wim to install.esd, 
    :: only including names matching Pattern (simple word).
    ::
    SETLOCAL EnableDelayedExpansion
    
    set _tempdir=F:\TEMP
    set _mountdir=%_tempdir%\mount
    set _scratchdir=%_tempdir%\dism
    
    set _name=
    set _desc=
    
    set rnum=%RANDOM%
    set _start=1
    set _stop=99
    
    IF "%~1"=="" (
       echo Usage: file [start-index] [stop-index] [pattern]
       GOTO :quit
    )
    
    IF NOT EXIST "%~f1" (
       echo ** ERROR: [%~f1] does not exist
       GOTO :quit
    )
    
    echo Working from [%~f1]...
    
    :startloop
    IF NOT [%3]==[] (
       set _start=%2
       set _stop=%3
    )
    echo Saving log to [%_tempdir%\errors_!rnum!.txt]
    echo Starting at index [!_start!] and stopping at or before [!_stop!]
    IF NOT [!_pattern!]==[] echo Using pattern [!_pattern!]
    FOR /L %%I in (!_start!,1,!_stop!) DO (
          echo ** Processing index [%%I]...
          call :getinfo "%~1" %%I
          IF [!_name!]==[] GOTO :done
          IF NOT "!_desc!"=="SKIPME_!rnum!" call :extracttoesd "%~1" %%I
       )
    )
    GOTO :done
    
    :errorlog
    echo ** %~1
    echo %~1 >> "%_tempdir%\%~n0_errors.!rnum!.txt"
    GOTO :eof
    
    :getinfo
    set _name=
    set _desc=
    dism /get-wiminfo /wimfile:"%~f1" /index:%2 > "%_tempdir%\%~n0_!rnum!.txt"
    FOR /f "tokens=2* delims=:" %%G in ('findstr /C:"Name" "%_tempdir%\%~n0_!rnum!.txt"') DO (
       set _name=%%G
    )
    IF NOT [!_name!]==[] ( 
       set _name=!_name:~1!
       IF [!_name!]==[!_name:%_pattern%=!] set _desc=SKIPME_!rnum!
    ) ELSE (
       call :errorlog "WARNING: Problem with getting name from index [%2] of [%~f1]"
    )
    IF [!_desc!]==[] (
       FOR /f "tokens=2* delims=:" %%G in ('findstr /C:"Description" "%_tempdir%\%~n0_!rnum!.txt"') DO (
          set _desc=%%G
       )
       IF NOT [!_desc!]==[] ( 
          set _desc=!_desc:~1!
       ) ELSE (
          call :errorlog "WARNING: Problem with getting description from index [%2] of [%~f1]"
       )
    )
    GOTO :eof
    
    :extracttoesd
    mkdir "%_mountdir%"
    echo ** Extracting index [%2] [!_name!] of [%~f1]...
    echo Y | del "%_tempdir%\temp_!rnum!.wim" >Nul 2>&1
    dism /get-wiminfo /wimfile:"%~f1" /index:%2 >Nul && dism /export-image /sourceimagefile:"%~f1" /sourceindex:%2 /destinationimagefile:"%_tempdir%\temp_!rnum!.wim" /checkintegrity /compress:none
    IF EXIST "%_tempdir%\temp_!rnum!.wim" (
       dism /export-image /sourceimagefile:"%_tempdir%\temp_!rnum!.wim" /sourceindex:1 /destinationimagefile:"%_tempdir%\install.esd" /checkintegrity /compress:recovery
       echo Y | del "%_tempdir%\temp_!rnum!.wim" >Nul
    ) ELSE (
       call :errorlog "ERROR: [%_tempdir%\temp_!rnum!.wim] doesn't seem to exist, aborting"
       call :errorlog "ERROR: Aborted on index [%2] of [%~f1]"
       GOTO :cleanup
    )
    GOTO :eof
    
    :done
    echo ** Task on [%~f1] complete.
    echo ** Log saved to [%_tempdir%\errors_!rnum!.txt].
    :cleanup
    echo Y | del "%_tempdir%\%~n0_!rnum!.txt" >Nul 2>&1
    echo Y | del "%_tempdir%\temp_!rnum!.wim" >Nul 2>&1
    
    :quit
    
    I also have esdtowim.bat and wimtowim.bat, but looking at the code now I really need to merge them all by just looking at the source extension (.wim or .esd) and adding an optional additional argument of a path to destination file (a WIM or ESD).

    As always, my code is public domain.
     
  6. Bilal84

    Bilal84 MDL Novice

    Mar 18, 2014
    25
    9
    0
    great work abbodi86 :tea::bananajoj2:
    amazing smiles :D
     
  7. alado221

    alado221 MDL Novice

    Nov 8, 2013
    3
    0
    0
    when i run the esd decryptor it jitters and distorts the screen. This happens even with my antivirus off, all the files being unlocked and nothing else checked on in file attributes.


    It also displays a msg saying " 'choise' is not recognized as an internal or external command, operable program or bath file.
    Any fixes to this?
     
  8. abbodi1406

    abbodi1406 MDL KB0000001

    Feb 19, 2011
    17,281
    91,248
    340
    #28 abbodi1406, Nov 13, 2014
    Last edited by a moderator: Apr 20, 2017
    Your system is Windows XP?
    choice.exe is not included with it

    download this, and put the file next to the script decrypt.cmd
    Code:
    ftp://ftp.microsoft.com/Services/TechNet/samples/PS/Win98/Reskit/SCRPTING/CHOICE.EXE
     
  9. alado221

    alado221 MDL Novice

    Nov 8, 2013
    3
    0
    0
    #29 alado221, Nov 13, 2014
    Last edited: Nov 13, 2014
    os: win7 ultimate sp1
    should i have installed a runtime package of some sort??
    doing stuff as told i promise. :help2:

    Edit: the same result in 4f.7 and in 3.7.

    however now when i add choice.exe the script is less distorted and it randomly shows another msg. and i quote
    CHOICE: invalid choice switch syntax syntax. Expected form: /C[:]choices
     
  10. abbodi1406

    abbodi1406 MDL KB0000001

    Feb 19, 2011
    17,281
    91,248
    340
    #30 abbodi1406, Nov 13, 2014
    Last edited by a moderator: Apr 20, 2017
    Well, in that case, something is not right in your system :)
    choice.exe is part of Win7

    and i tested the package successfully on win7, both x86 & x64

    anyway, which one of these options you want to use?
    Code:
    1 - Create Full ISO with Standard install.wim
    2 - Create Full ISO with Compressed install.esd
    
    i could make you a slimmed decrypt.cmd without choices
     
  11. alado221

    alado221 MDL Novice

    Nov 8, 2013
    3
    0
    0
    turns out system32 was not part of my path variable!!! *facepalming with two hands*

    This is what i get for using a borrowed laptop. Thanks for all the effort
    :worthy:abbodi1406
     
  12. Zuzuitu

    Zuzuitu MDL Novice

    Dec 1, 2014
    4
    1
    0
    Hello. Good script. Works even if i have 6 indexes ? Because at 4 stops..
     
  13. abbodi1406

    abbodi1406 MDL KB0000001

    Feb 19, 2011
    17,281
    91,248
    340
    Stops how?

    to be honest, i tested it for 3 only
     
  14. Zuzuitu

    Zuzuitu MDL Novice

    Dec 1, 2014
    4
    1
    0
    Says that dism stoped working. Any fix? Thanks
     
  15. abbodi1406

    abbodi1406 MDL KB0000001

    Feb 19, 2011
    17,281
    91,248
    340
    What's your host system?
    i can't fix dism errors :)

    I'll try to make a wimlib-based script
     
  16. Zuzuitu

    Zuzuitu MDL Novice

    Dec 1, 2014
    4
    1
    0
    I have Windows 8.1 Pro x64, thanks in advance!
     
  17. s1ave77

    s1ave77 Has left at his own request

    Aug 15, 2012
    16,093
    24,398
    340
    #37 s1ave77, Dec 2, 2014
    Last edited by a moderator: Apr 20, 2017
    With that error i would check my system files integrity first.


    In admin command prompt:
    Code:
    sfc /scannow
    (In case of errors are reported reboot the system, in order to repair them.)
    Scan/Restore Windows Component Store (In admin command prompt):
    Code:
    dism /online /cleanup-image /scanhealth 
    dism /online /cleanup-image /restorehealth 
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  18. Zuzuitu

    Zuzuitu MDL Novice

    Dec 1, 2014
    4
    1
    0
    I tried on my laptop now and everything was fine. I will check my desktop for those errors. Thanks for everything, Cheers
     
  19. abbodi1406

    abbodi1406 MDL KB0000001

    Feb 19, 2011
    17,281
    91,248
    340
    #39 abbodi1406, Dec 4, 2014
    Last edited by a moderator: May 23, 2017
    ESD <> WIM Conversion Script

    Added the wimlib-based version, and updated the dism-based



    Test note:

    ESD -> WIM:
    wimlib-imagex is slightly faster or similar to dism, install.wim size is also slightly smaller or similar

    WIM -> ESD:
    wimlib-imagex is alot faster than dism, but install.esd created by dism is smaller

    i.e. in my test the size difference is about 65 MB, but dism took almost double the time (90 minutes) comparing to wimlib (50 minutes)
     
  20. Mr.X

    Mr.X MDL Guru

    Jul 14, 2013
    8,556
    15,643
    270
    #40 Mr.X, Dec 4, 2014
    Last edited by a moderator: May 23, 2017
    65 MB one index wim or a mult-index wim?