Request for user testing a batch file that handles large install.wim


  1. Posts : 15,441
    Windows10
       #1

    Request for user testing a batch file that handles large install.wim


    I created a tutorial for creating a usb installation drive with a custom install.wim greater than 4GB.

    Create bootable USB installer if install.wim is greater than 4GB | Windows 10 Tutorials

    I have been upgrading the batch file so it creates the diskpart.dat and ei.cfg files automatically

    I would like some user feedback.

    It is quite easy to customise now.

    Main things to set are

    1) drive and path to where the installation files are - they can be a mounted iso or any directory
    2) disk number of usb drive when inserted - use diskpart list disk to identify or look in disk management
    The script here initially sets it as 99 to avoid deleting a drive if you do not change the number
    3) drive and path to where install.wim is if different location (set WIMDIFFLOC to 1)

    For the purposes of testing, it does not really matter if install.wim is less than 4GB.

    Simply copy all the code into a batch text file e.g. usbcreate.bat, customise as above and run with admin rights.

    You need an 8GB drive as a minimum, and all files on drive will be wiped. Original source files are only copied and never affected.

    Code:
    
    echo on
    
    REM ------------------------------------------------------------------------------
    
    REM SET DRIVE LETTER AND PATH OF SOURCE ISO OR DIRECTORY FILES
    
    REM MAKE SURE NO TRAILING BLANKS AND PATH FINISHES WITH A \
    
    SET SOURCEFILES=D:\
    
    REM IF CUSTOM INSTALL.WIM IS NOT IN SOURCES DIRECTORY, SET WIMDIFFLOC TO 1
    
    SET WIMDIFFLOC=0
    
    REM SET DRIVE LETTER OF CUSTOM INSTALL.WIM
    
    REM MAKE SURE NO TRAILING BLANKS AND PATH FINISHES WITH A \
    
    SET WIMFILE=D:\SOURCES\
    
    REM SET USB FAT32 AND NTFS DRIVE LETTERS  (USE HIGHER LETTERS YOU DO NOT USE NORMALLY)
    
    SET FAT32DRV=U
    
    SET NTFSDRV=V
    
    REM SET DRIVE NUMBER OF USB DRIVE - WARNING BE VERY CAREFUL YOU GET THIS RIGHT
    
    REM DEFAULT IS SET TO INITIALLY TO 99 TO PREVENT ACCIDENTAL WIPING OF A DRIVE
    
    REM YOU CAN CHANGE DEFAULT IF YOU ALWAYS KNOW WHAT DRIVE NUMBER IS ASSIGNED
    
    REM TYPICALLY IT WILL BE THAT LAST NUMBER IN DRIVE AND EQUAL TO NUMBER OF INTERNAL HARD DRIVES
    
    SET USBDRV=99
    
    REM --------------------------------------------------------------------------------
    
    C:
    
    CD\
    
    rd "usbcreate" /s /q
    
    md \usbcreate
    
    cd \usbcreate
    
    md "baseiso"
    
    
    xcopy %SOURCEFILES%*.* "c:\usbcreate\baseiso\" /s /y /q
    
    IF %WIMDIFFLOC%==0 GOTO :CONT1
    
    xcopy %WIMFILE% "c:\usbcreate\baseiso\" /s /y /q
    
    :CONT1
    
    REM ---------------------------------------------------------------------------------------------
    
    REM CREATE DISKPART.DAT
    
    echo select disk %USBDRV% > c:\usbcreate\diskpart.dat
    
    echo clean  >> c:\usbcreate\diskpart.dat
    
    echo convert mbr >> c:\usbcreate\diskpart.dat
    
    echo create partition primary size=1000 >> c:\usbcreate\diskpart.dat
    
    echo create partition primary >> c:\usbcreate\diskpart.dat
    
    echo select partition 1 >> c:\usbcreate\diskpart.dat
    
    echo format fs=fat32 quick >> c:\usbcreate\diskpart.dat
    
    echo assign letter=%FAT32DRV% >> c:\usbcreate\diskpart.dat
    
    echo active >> c:\usbcreate\diskpart.dat
    
    echo select partition 2 >> c:\usbcreate\diskpart.dat
    
    echo format fs=ntfs quick >> c:\usbcreate\diskpart.dat
    
    echo assign letter=%NTFSDRV% >> c:\usbcreate\diskpart.dat
    
    echo exit >> c:\usbcreate\diskpart.dat
    
    diskpart /s "c:\usbcreate\diskpart.dat"
    
    echo Exit Code is %errorlevel%
    
    if %errorlevel%==0 goto :CONT2
    
    REM DO DISKPART AGAIN IF IT FAILS FIRST TIME - NO IDEA WHY THAT HAPPENS SOMETIMES  BUT USUALLY WORKS 2ND TIME
    
    diskpart /s "c:\usbcreate\diskpart.dat"
    
    echo Exit Code is %errorlevel%
    
    if %errorlevel%==0 goto :CONT2
    
    echo Diskpart has failed twice - procedure is aborted
    
    echo You can manually partition flash drive and remove this whole section. 
    
    goto :CONT3
    
    :CONT2
    
    label %fat32drv%:USB-FAT32
    
    label %ntfsdrv%:USB-NTFS
    
    REM --------------------------------------------------------------------------------------------
    
    xcopy "c:\usbcreate\baseiso\*.*" %NTFSDRV%:\ /s /y /q
    
    rd "c:\usbcreate\baseiso\sources\" /s /q
    
    md "c:\usbcreate\baseiso\sources\"
    
    xcopy "c:\usbcreate\baseiso\*.*" %FAT32DRV%:\ /s /y /e /q
    
    xcopy "%NTFSDRV%:\sources\boot.wim" "%FAT32DRV%:\sources\" /y /q
    
    REM --------------------------------------------------------------------------------------------
    
    REM CREATE EI.CFG IN SOURCES FOLDER
    
    echo [CHANNEL] > "%NTFSDRV%:\sources\ei.cfg"
    
    echo Retail >> "%NTFSDRV%:\sources\ei.cfg"
    
    REM ---------------------------------------------------------------------------------------------
    
    :CONT3
    
    pause
    
    
    Last edited by cereberus; 09 Nov 2018 at 15:22.
      My Computer


  2. Posts : 31,471
    10 Home x64 (22H2) (10 Pro on 2nd pc)
       #2

    Q: is not a good drive letter to use in your .bat. Typically it is used by MS for 'Click-to-run' software like MS Office.

    Request for user testing a batch file that handles large install.wim-image.png
      My Computers


  3. Posts : 15,441
    Windows10
    Thread Starter
       #3

    Bree said:
    Q: is not a good drive letter to use in your .bat. Typically it is used by MS for 'Click-to-run' software like MS Office.

    Request for user testing a batch file that handles large install.wim-image.png
    OK will change when I get a moment.
      My Computer


  4. Posts : 4,511
    several
       #4

    REM SET DRIVE LETTER AND PATH OF SOURCE ISO OR DIRECTORY FILES
    Code:
    REM MAKE SURE NO TRAILING BLANKS AND PATH FINISHES WITH A \
    SET SOURCEFILES=D:\
    REM IF CUSTOM INSTALL.WIM IS NOT IN SOURCES DIRECTORY, SET WIMDIFFLOC TO 1
    SET WIMDIFFLOC=0
    REM SET DRIVE LETTER OF CUSTOM INSTALL.WIM
    REM MAKE SURE NO TRAILING BLANKS AND PATH FINISHES WITH A \
    SET WIMFILE=D:\SOURCES\


    You can include a browse function easily by using my adapted version of pecmd.
    Code:
    @Echo off
    mode con: lines=61
    color 1F
    SET TP=%~dp0
    SET TP=%TP:~0,-1%
    cd /d "%TP%"
    :selwimdir
    ECHO. & ECHO PLEASE SELECT THE PATH OF THE WINDOWS INSTALLATION FILES
    ECHO. & ECHO.
    start /wait BIN\pecmd load %tp%\BIN\getwimdir.ini
    call BIN\setWimdirpath.cmd
    del BIN\setWimdirpath.cmd >nul
    IF '%Wimdirpath%'=='' goto selwimdir
    if not exist %Wimdirpath% (
    echo   NO DIRECTORY SELECTED
    goto selwimdir
    )
    REM CHECK FOR install.wim 
    echo.
    set wimdir=%wimdirpath:~1,-1%
    echo.
    set inswimpath="%wimdir%\sources\install.wim"
    echo.
    if not exist %INSWimpath% (
    echo %INSWimpath% NOT FOUND
    goto selwimdir
    )
    echo.
    IF EXIST "%wimdir%\sources\ei.cfg" (
     REN "%wimdir%\sources\ei.cfg" ei.cfg.bak >nul
      )
    echo.
    REM CHECK FOR boot.wim 
    set bootwimpath="%wimdir%\sources\boot.wim"
    if not exist %bootWimpath% (
    echo %bootWimpath% NOT FOUND
    goto selwimdir
    )

    browse.zip
    Last edited by SIW2; 09 Nov 2018 at 12:30.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 23:34.
Find Us




Windows 10 Forums