Win 10 USB install Fails, Linux has no problem

Page 1 of 3 123 LastLast

  1. Posts : 8
    Win 10
       #1

    Win 10 USB install Fails, Linux has no problem


    This one is driving me bonkers.

    With a USB drive, Win 20 blue screens with a Critical error 0xc000021a as it's loading the files from the USB and before it displays the Windows logo.

    Ubuntu and ClearLinux installed without a hitch.

    I have tried the following
    • Changed Memory (with other new sticks)
    • Changed M2 drives and tried a new SATA drive on its own
    • Tried three different Win 10 ISO builds on two different USB drives
    • Tried a Win 8 ISO build to see if that would work
    • Used Rufus with with legacy and secure boot options
    • Tried the Microsoft Media Creation Tool for good measure
    • BIOS shows everything working fine, but updated BIOS just in case.
    • Removed CMOS battery for factory default, because I'm running out of options
    • Installed a mounted/bootable drive in Linux to boot to... same crash issue
    • Lit candles and made a pentagram with salt in middle of my office and cried. That only made a mess.


    New machine. Nothing that shouldn't be on the HCL

    AMD Ryzen 3960 (mounted fine, mobo and linux OS see all of it)
    32GB ram
    Gigbyte TRX40 Aorus Master Mobo
    NVidia Quadro video card
    M2 and SATA drive
      My Computer


  2. Posts : 2,773
    Windows 11 Pro, 21H2
       #2

    Welcome to TenForums!

    Bytebait,

    Could you provide a little bit more detail on how you are trying to install Windows? Here are some specific questions that I have:

    EDIT: I must be reading impaired. You answered a lot of my original questions. Give me a moment and I'm going to provide some steps for you to try. This is my preferred method. Will post in a few minutes.
      My Computers


  3. Posts : 2,773
    Windows 11 Pro, 21H2
       #3

    Download the Media Creation Tool and run it. Choose to create installation media, make sure you have 64-bit (x64) selected, uncheck "Use the recommended options for this PC", choose to save the ISO file.

    save the code below to a text file and name it something like "Create Boot Media.bat". Use something like Notepad that won't put special formatting characters into the file.
    Code:
    @echo off
    
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: This batch file will allow you to create a Windows installation disk. This can be a flash drive or a HD.  ::
    :: It is designed to create a drive that will boot on either a BIOS or UEFI based system and it is perfectly ::
    :: fine for any files in the installation media to be larger than 4 GB.                                      ::
    ::                                                                                                           ::
    :: Created December 2020 by HSehestedt and ZTrucker                                                          ::
    :: Last updated Apr 15, 2021                                                                                 ::
    ::                                                                                                           ::
    :: Version 1.01.00                                                                                           ::
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: Explanation of User Customizable Settings::                                                                    ::
    ::::::::::::::::::::::::::::::::::::::::::::::                                                                    ::
    :: Set the variables below to customize the behavior of the batch file.                                           ::
    ::                                                                                                                ::
    :: Important: Values are case sensitive. Use capital letters only!                                                ::
    ::                                                                                                                ::
    :: HideDetails - Set to "Y" to hide the details of every file being copied. Set to "N" or anything other than     ::
    ::    "Y" to show the detailed copy status. May be helpful for troubleshooting.                                   ::
    ::                                                                                                                ::
    :: Partition1Size - This specifies the size in MB to create the first FAT32 partition. Suggestion: 2000 MB        ::
    ::    (equal to 2GB) should be a good value for almost any situation. Use a number only (no MB after the number). ::
    ::                                                                                                                ::
    :: Part2SizeLimit - Set to either "N" or a numerical value. If you set this to "N", the size of the 2nd           ::
    ::    partition will be unlimited and will be created with all the remaining space not used by partition 1. If    ::
    ::    you would like to limit the size of the partition, specify a size in MB to create this partition.           ::
    ::    Note: 1 GB would be 1000 and 1 TB would be 1000000 (DON'T USE A COMMA IN VALUE!).                           ::
    ::                                                                                                                ::
    :: Partition1Name - This is the volume label to give the first partition. Since this is a FAT32 partition, the    ::
    ::    volume label is limited to 11 characters.                                                                   ::
    ::                                                                                                                ::
    :: Partition2Name - This is the volume label to give the second partition. Since this is an exFAT partition, the   ::
    ::    volume label is limited to 11 characters.                                                                   ::
    ::                                                                                                                ::
    :: PartType - Set to either MBR or GPT. Normally, leave this set to MBR. An MBR partition type will allow for the ::
    ::    greatest compatibility with both BIOS and UEFI based systems. However, it is limited to disks with up to    ::
    ::    2TB in size. If you plan to use a disk larger than 2TB you must specify a GPT partition type. Please be     ::
    ::    aware that doing this will limit compatibility of the boot disk with BIOS based systems.                    ::
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    set HideDetails=N
    set Partition1Size=2000
    set Part2SizeLimit=20000
    set Partition1Name=PAR-1-FAT32
    set Partition2Name=PAR-2-exFAT
    set PartType=MBR
    
    :start
    
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: If the user wants to hide the details of files being copied, we append a "/nfl /ndl" to the end     ::
    :: of robocopy commands. By setting a flag to either nothing or to "/nfl /ndl" we can use the same     ::
    :: commands and the variable "flag" at the end of each command will determine how the command behaves. ::
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    if %HideDetails%==Y (
    set flag=/nfl /ndl
    ) ELSE (
    set flag=
    )
    
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: Enable Delayed Expansion and Extensions, and change to the directory where the batch file is located. ::
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    setlocal enabledelayedexpansion
    setlocal enableextensions
    cd /d %~dp0
    
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: Check to see if this batch file is being run as Administrator. If it is not, then rerun the batch file ::
    :: automatically as admin and terminate the intial instance of the batch file.                            ::
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    openfiles > NUL 2>&1 
    if NOT %ERRORLEVEL% EQU 0 (
    powershell.exe start-process '%~f0' -verb runas
    exit
    )
    
    ::::::::::::::::::::::::::::::::::::::::::::::::
    :: End Routine to check if being run as Admin ::
    ::::::::::::::::::::::::::::::::::::::::::::::::
    
    :IsAdmin
    
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: We reach this point once the batch file is run as admin ::
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: Change the console mode to 120 columns wide by 25 lines high ::
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    mode con: cols=120 lines=25
    
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: Ask user for location of mounted ISO image or the directory containing the Windows files. ::
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    cls
    echo Introduction
    echo ============
    echo.
    echo This batch file will create a bootable flash drive from a mounted Windows ISO image or an image extracted to disk.
    echo If you are using an ISO image, mount it before you continue by double-clicking the ISO image and note the drive
    echo letter to which it is mounted.
    echo.
    echo You will be asked if you want to wipe the destination disk or perform a refresh operation. If this is the first
    echo time preparing the disk, use the WIPE option. Be aware that this will destroy ALL data currently on the disk!
    echo.
    echo If you choose the REFRESH option, you will be asked for the drive letter of the two partitions previously
    echo created on the disk. We will then replace the files on these partitions with those from the source that you
    echo specify. This is especially helpful if you create additional partitions on the disk because it will leave
    echo those partitions intact.
    echo.
    pause
    cls
    echo Do you want to perform a WIPE operation or a REFRESH operation?
    echo.
    choice /C WR /N /M "Press W or R to respond:"
    if errorlevel 2 set WipeRefresh=REFRESH & goto GetSourcePath
    if errorlevel 1 set WipeRefresh=WIPE & goto GetSourcePath
    
    :GetSourcePath
    
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: Get the path to the Windows source files.                           ::
    :: Tip: The path can end with or without a backslash (\). For example, ::
    :: either D:, D:\, D:\ISO_Files, D:\ISO_Files\ are all valid paths.    ::
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    cls
    echo Enter the path to the SOURCE where your Windows files are located below.
    echo.
    :GetSourcePath
    set /p SourcePath="Enter source path: "
    
    :: Add a trailing backslash (\) if one does not exist
    
    IF NOT "%SourcePath:~-1%"=="\" (
    set SourcePath=%SourcePath%\
    )
    
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: Any valid Windows boot media will have a file called "boot\bootfix.bin" on the drive. This is true for both ::
    :: single architecture images (x64 or x86) or for images with dual architectures. We will do a simple check to ::
    :: see if such a file exists as a basic test for a valid source image location.                                ::
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    if NOT EXIST %SourcePath%boot\bootfix.bin (
    cls
    echo The location that you specified does not contain a valid Windows image. Please try another location.
    echo If you are specifying a location on disk, please be sure to specify the location to the root of the
    echo Windows image. If you are using an ISO image, you should double-click the ISO image to mount it and
    echo note the drive letter to which it was mounted.
    echo.
    goto GetSourcePath
    )
    
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: The directory structure for a dual architecture image (one that has BOTH x64 and x86 images) will include    ::
    :: \x64 and \x86 folders. In order for us to properly handle this, we need to determine if the source specified ::
    :: is a single of dual architecture image. To do so, we will simply check for the existance on a \x64 folder.   ::
    :: The variable Architecture will be set to either SINGLE or DUAL.                                              ::
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    if exist %SourcePath%\x64 (
    set Architecture=DUAL
    ) ELSE (
    set Architecture=SINGLE
    )
    
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: If a refresh operation was selected, then we need to ask the user for the drive letter associated with the ::
    :: FAT32 and exFAT partitions. Otherwise, we need to identify what disk will be wiped.                        ::
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    If %WipeRefresh%==WIPE goto GetDiskNum
    
    :GetPar1Letter
    
    cls
    echo Please enter the drive letter of the FIRST partition (the FAT32 partition) on the disk that we will refresh. Please
    echo enter a drive letter only with no colon (:).
    echo.
    set /P Partition1="Drive letter of FIRST partition: "
    
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: As a safety check, verify that the first partition has a file \boot\bootfix.bin ::
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    if exist %Partition1%:\boot\bootfix.bin goto GetPar2Letter
    cls
    echo ERROR! Either the drive letter you specified does not exist or it does not seem to contain a previously
    echo created partition with suitable Windows installation files.
    echo.
    echo Please verify that you have specified the correct drive letter.
    echo.
    pause
    goto GetPar1Letter
    
    :GetPar2Letter
    
    cls
    echo Please enter the drive letter of the SECOND partition (the exFAT partition) on the disk that we will refresh. Please
    echo enter a drive letter only with no colon (:).
    echo.
    set /P Partition2="Drive letter of SECOND partition: "
    
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: As a safety check, verify that the second partition has either a \Sources or a \x64 folder ::
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    if exist %Partition2%:\Sources goto Par2Valid
    if exist %Partition2%:\x64 goto Par2Valid
    
    cls
    echo ERROR! Either the drive letter you specified does not exist or it does not seem to contain a previously
    echo created partition with suitable Windows installation files.
    echo.
    echo Please verify that you have specified the correct drive letter.
    echo.
    pause
    goto GetPar2Letter
    
    :Par2Valid
    
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: Since we are performing a refresh operation, there is no need for us to get a disk number. We will ::
    :: skip that and proceed to the summary screen.                                                       ::
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    goto Summary
    
    :GetDiskNum
    
    :::::::::::::::::::::::::::::::::::::::::::::::::
    :: Display a list of disks seen by the system. ::
    :::::::::::::::::::::::::::::::::::::::::::::::::
    
    cls
    (echo list disk
    echo exit
    ) | diskpart
    
    echo.
    echo Above is a list of disks connected to your system. Scroll up if the list is too long.
    echo CAUTION: *MAKE SURE* that you specify the correct disk because it will be erased. Press CTRL-C to abort.
    echo.
    set /p DiskID="Enter the disk number for the DESTINATION disk (Enter only the number and press ENTER): "
    
    if [%DiskID%] EQU [] Goto GetDiskNum
    
    :Summary
    
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: Display a summary of options that will be used and get confirmation ::
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    cls
    echo Summary of options you have selected:
    echo.
    
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: These summary items apply to both WIPE and REFRESH operations ::
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    echo Path for the source files: %SourcePath%
    
    if %HideDetails%==Y (
    echo File copy status details WILL NOT be displayed
    ) ELSE (
    echo File copy status details WILL be displayed
    )
    
    
    
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: The summary items below apply only to WIPE operations, so if a ::
    :: REFRESH is being performed, skip this section                  ::
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    if %WipeRefresh%==REFRESH goto RefreshSummary
    
    echo Drive number to make bootable: %DiskID%
    echo Partition type: %PartType%
    echo Partition 1 size: %Partition1Size% MB
    
    if %Part2SizeLimit%==Y (
    echo Partition 2 size: %Part2SizeLimit% MB
    ) ELSE (
    echo Partition 2 size: Use all remaining space
    )
    
    echo Partition 1 volume label: %Partition1Name%
    echo Partition 2 volume label: %Partition2Name%
    
    goto GetConfirmation
    
    :RefreshSummary
    
    ::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: These items apply only to a REFRESH operation. ::
    ::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    echo Drive letter of FIRST partition to refresh: %Partition1%:
    echo Drive letter of SECOND partition to refresh: %Partition2%:
    
    :GetConfirmation
    
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: Time to get final confirmation from user. If the user does not confirm ::
    :: that everything is correct, show some possible resolutions.            ::
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    echo.
    choice /C YN /N /M "Is this correct? (Press Y or N to respond):"
    if errorlevel 2 (
    cls
    echo.
    echo        Symptom                                            Corrective Action
    echo        =======                                            =================
    echo Source path is wrong:                 Run the program again and respond with the correct path
    echo Wrong drive number for a WIPE:        Run the program again and respond with the correct drive number
    echo Wrong drive letters for a REFRESH:    Run the program again and respond with the correct drive letters
    echo File copy status display incorrect:   Change the setting of "HideDetails" at start of program
    echo Wrong partition sizes:                Change the setting of "Partition1Size" or "Part2SizeLimit" at start of program
    echo Wrong volume labels for a WIPE:       Change the setting of "Partition1Name" or "Partition2Name" at start of program
    echo Wrong partition type:                 Change the setting of "PartType" at start of program
    echo.
    pause
    exit
    )
    
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: We are creating 2 partions. A FAT32 partition and an exFAT partition. We only need the sources folder ::
    :: on the NFTS partition. On the FAT32 partition, we want everything else. We also want the single file  ::
    :: called BOOT.WIM in the sources folder on the FAT32 partition.                                         ::
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    cls
    if %WipeRefresh%==WIPE echo We are partitioning the destination drive and copying files.
    if %WipeRefresh%==REFRESH echo We are formatting drives %Partition1%: and %Partition2%:    and copying files. Other partitions will be left alone.
    echo Please be patient^^! This can take a while especially if your drive is slow.
    echo.
    
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: If we are performing a REFRESH, then there are a lot of steps that we can skip. ::
    :: As a result, we will skip to the CopyOperations section.                     ::
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    if %WipeRefresh%==REFRESH goto CopyOperations
    
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: We will first wipe the selected disk. This will free up any drive letters currently used by that disk. ::
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    (echo select disk %DiskID%
    echo clean
    echo convert %PartType%
    echo rescan
    echo exit
    ) | diskpart > nul
    
    ::::::::::::::::::::::::::::::::::::::::::::::::
    :: Determine the first available drive letter ::
    ::::::::::::::::::::::::::::::::::::::::::::::::
    
    for %%a in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do if not exist %%a:\nul (
    set Partition1=%%a
    goto DriveLetter1Found
    )
    :DriveLetter1Found
    
    echo The first partition will be assigned drive letter %Partition1%: and will be formatted with FAT32.
    
    (echo select disk %DiskID%
    echo create partition primary size=%Partition1Size%
    echo select partition 1
    echo format fs=fat32 quick
    echo assign letter=%Partition1%
    echo active
    echo rescan
    echo exit
    ) | diskpart > nul
    
    :::::::::::::::::::::::::::::::::::::::::::::::
    :: Determine the next available drive letter ::
    :::::::::::::::::::::::::::::::::::::::::::::::
    
    for %%a in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do if not exist %%a:\nul (
    set Partition2=%%a
    goto DriveLetter2Found
    )
    :DriveLetter2Found
    echo The second partition will be assigned drive letter %Partition2%: and will be formatted with exFAT.
    echo.
    
    if %Part2SizeLimit%=="N" goto NoSizeLimit
    
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: User has elected to create the second partition with a specific size ::
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    (echo select disk %DiskID%
    echo create partition primary size=%Part2SizeLimit%
    echo format fs=exfat quick
    echo assign letter=%Partition2%
    echo rescan
    echo exit
    ) | diskpart > nul
    
    :NoSizeLimit
    
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: User has elected create the second partition with all remaining space ::
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    (echo select disk %DiskID%
    echo create partition primary
    echo format fs=exfat quick
    echo assign letter=%Partition2%
    echo rescan
    echo exit
    ) | diskpart > nul
    
    :PartitionsCreated
    
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: Set volume labels on the two partitions that we just created. ::
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    label %Partition1%:%Partition1Name%
    label %Partition2%:%Partition2Name%'
    
    :CopyOperations
    
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: This section is for the copy operations from SOURCE to DESTINATION ::
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: Technical Notes:                                                                                                 ::
    ::                                                                                                                  ::
    :: Some flash drives present themselves as a fixed disk and as a result they my have a recyle bin folder on them.   ::
    :: are excluding the system folders which includes the recycle bin from the following operation. The /njh and /njs  ::
    :: switches prevent robocopy from displaying the header and summary information. If you want to stop robocopy from  ::
    :: displaying file copy progress just add a /nfl /ndl (No File Listing and No Directory Listing) to each robocopy   ::
    :: command. Note that if the user elected to hide details of the copy operation, then the variable "flag" will be   ::
    :: set to "/nfl /ndl" which will hide the directory and file listings.                                              ::
    ::                                                                                                                  ::
    :: For reasons unknown to me, sometimes a path enclosed in quotes does not work in robocopy unless you add a        ::
    :: trailing space. In the below commands I found this to be true only on the first robocopy command but I've added  ::
    :: the space to all commands for consistency. We need the quotes just in case a path with spaces in the name is     ::
    :: specified.                                                                                                       ::
    ::                                                                                                                  ::
    :: It was previously necessary to create a file named ei.cfg in the \Sources foler. Technically, this file is only  ::
    :: needed if you are NOT using an AUTOUNATTEND.XML answer file, but it won't hurt to have it there anyway. However, ::
    :: in my testing, it seems that this file is no longer necessary. As a result, the code to create that file is      ::
    :: commented out below but I have not removed it just in case it is needed again.                                   ::
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    if %Architecture%==DUAL goto DualArchitecture
    
    :: Copying files to the FAT32 partition
    
    robocopy "%SourcePath% " %Partition1%:\ /mir /xd sources "system volume information" $recycle.bin /njh /njs %flag%
    robocopy "%SourcePath%sources " %Partition1%:\sources boot.wim /njh /njs %flag%
    
    :: Copying files to the exFAT partition
    
    robocopy "%SourcePath%sources " %Partition2%:\sources /mir /njh /njs /xf boot.wim %flag%
    robocopy %Partition1%:\ %Partition2%:\ /mov autounattend*.xml %flag%
    
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: Technical note: It was previously necessary to create a file named ei.cfg in the \Sources foler. Technically,  ::
    :: this file is only needed if you are NOT using an AUTOUNATTEND.XML answer file, but it won't hurt to have it    ::
    :: there anyway. However, in my testing, it seems that this file is no longer necessary. As a result, the code to ::
    :: create that file is commented out below but I have not removed it just in case it is needed again.             ::
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    :: echo [CHANNEL] > %Partition2%:\sources\ei.cfg
    :: echo Retail >> %Partition2%:\sources\ei.cfg
    
    goto DoneCopying
    
    :DualArchitecture
    
    :: Copying files to the FAT32 partition
    
    robocopy "%SourcePath% " %Partition1%:\ /mir /xd sources x64 x86 "system volume information" $recycle.bin /njh /njs %flag%
    robocopy "%SourcePath%x64\sources " %Partition1%:\x64\sources boot.wim /njh /njs %flag%
    robocopy "%SourcePath%x86\sources " %Partition1%:\x86\sources boot.wim /njh /njs %flag%
    
    :: Copying files to the exFAT partition
    
    robocopy "%SourcePath%x64\sources " %Partition2%:\x64\sources /mir /njh /njs /xf boot.wim %flag%
    robocopy "%SourcePath%x86\sources " %Partition2%:\x86\sources /mir /njh /njs /xf boot.wim %flag%
    robocopy %Partition1%:\ %Partition2%:\ /mov autounattend*.xml %flag%
    
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: Technical note: It was previously necessary to create a file named ei.cfg in the \Sources foler. Technically,  ::
    :: this file is only needed if you are NOT using an AUTOUNATTEND.XML answer file, but it won't hurt to have it    ::
    :: there anyway. However, in my testing, it seems that this file is no longer necessary. As a result, the code to ::
    :: create that file is commented out below but I have not removed it just in case it is needed again.             ::
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    :: echo [CHANNEL] > %Partition2%:\x64\sources\ei.cfg
    :: echo Retail >> %Partition2%:\x64\sources\ei.cfg
    
    :: echo [CHANNEL] > %Partition2%:\x86\sources\ei.cfg
    :: echo Retail >> %Partition2%:\x86\sources\ei.cfg
    
    :DoneCopying
    
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: Inform the user that we are done. Also, as a precaution, check to see if an ::
    :: unattended setupanswer file is present and warn the user if it is.          ::
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    cls
    echo All operations have been completed.
    echo.
    
    if exist %Partition2%:\autounattend.xml (
    echo ^^!CAUTION^^! An unattended setup file ^(autounattend.xml^) is present on the 2nd partition.
    echo As a result, if you boot from this disk, an unattended installation will begin. This has
    echo the potential to wipe out the contents of disks attached to your system without warning.
    echo.
    )
    pause
    
    :END
    
    exit

    Mount the Windows ISO file that you download by double-clicking it. Note what drive letter the image is mounted to.

    Run the batch file that you just saved.

    Press "ENTER" on the intro screen.

    Press "W" to select a "Wipe" operation. This will wipe out the contents of the flash drive.

    Enter the drive letter for the Windows image. As an example, if you noted earlier that it was mounted to drive E:, then enter E:\

    The batch file will run DISKPART to show you a list of all drives on the system. Take note of the disk number for your USB drive (hopefully the disk size will make obvious what the correct disk number is). Enter that disk number.

    You will see a summary screen displayed. Press "Y" if everything looks correct.

    The media will now be created.

    If this media works for you, let me know and I'll explain what's special about this method.
      My Computers


  4. Posts : 2,773
    Windows 11 Pro, 21H2
       #4

    @Bytebait, if you have not tried the script I provided in the the previous posting, go ahead and grab the one below instead.

    The one above should work, but I made a few quick enhancements to this one. Please do let me know if this works for you!

    Code:
    @echo off
    
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: This batch file will allow you to create a Windows installation disk. This can be a flash drive or a HD.  ::
    :: It is designed to create a drive that will boot on either a BIOS or UEFI based system and it is perfectly ::
    :: fine for any files in the installation media to be larger than 4 GB.                                      ::
    ::                                                                                                           ::
    :: Created December 2020 by HSehestedt and ZTrucker                                                          ::
    :: Last updated Apr 15, 2021                                                                                 ::
    ::                                                                                                           ::
    :: Version 1.02.00                                                                                           ::
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: Explanation of User Customizable Settings::                                                                    ::
    ::::::::::::::::::::::::::::::::::::::::::::::                                                                    ::
    :: Set the variables below to customize the behavior of the batch file.                                           ::
    ::                                                                                                                ::
    :: Important: Values are case sensitive. Use capital letters only!                                                ::
    ::                                                                                                                ::
    :: HideDetails - Set to "Y" to hide the details of every file being copied. Set to "N" or anything other than     ::
    ::    "Y" to show the detailed copy status. May be helpful for troubleshooting.                                   ::
    ::                                                                                                                ::
    :: Partition1Size - This specifies the size in MB to create the first FAT32 partition. Suggestion: 2000 MB        ::
    ::    (equal to 2GB) should be a good value for almost any situation. Use a number only (no MB after the number). ::
    ::                                                                                                                ::
    :: Part2SizeLimit - Set to either "N" or a numerical value. If you set this to "N", the size of the 2nd           ::
    ::    partition will be unlimited and will be created with all the remaining space not used by partition 1. If    ::
    ::    you would like to limit the size of the partition, specify a size in MB to create this partition.           ::
    ::    Note: 1 GB would be 1000 and 1 TB would be 1000000 (DON'T USE A COMMA IN VALUE!). Limiting the size is      ::
    ::    useful if you want to add other partitions to the drive.                                                    ::
    ::                                                                                                                ::
    :: Part2FS - This sets the filesystem type to use on the 2nd partition. Normally I would suggest exFAT but NTFS   ::
    ::    is also acceptable. Set this value to either "exFAT" or "NTFS". CAUTION: This IS case sensitive.            ::
    ::                                                                                                                ::
    :: Partition1Name - This is the volume label to give the first partition. Since this is a FAT32 partition, the    ::
    ::    volume label is limited to 11 characters.                                                                   ::
    ::                                                                                                                ::
    :: Partition2Name - This is the volume label to give the second partition. If you choose to use exFAT you are     ::
    ::    limited to 11 characters. With NTFS you have up to 32 characters.                                           ::
    ::                                                                                                                ::
    :: PartType - Set to either MBR or GPT. Normally, leave this set to MBR. An MBR partition type will allow for the ::
    ::    greatest compatibility with both BIOS and UEFI based systems. However, it is limited to disks with up to    ::
    ::    2TB in size. If you plan to use a disk larger than 2TB you must specify a GPT partition type. Please be     ::
    ::    aware that doing this will limit compatibility so that it will not work on BIOS based systems.              ::
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    set HideDetails=N
    set Partition1Size=2000
    set Part2SizeLimit=N
    set Part2FS=NTFS
    set Partition1Name=PAR-1-FAT32
    set Partition2Name=PAR-2-%Part2FS%
    set PartType=MBR
    
    :start
    
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: If the user wants to hide the details of files being copied, we append a "/nfl /ndl" to the end     ::
    :: of robocopy commands. By setting a flag to either nothing or to "/nfl /ndl" we can use the same     ::
    :: commands and the variable "flag" at the end of each command will determine how the command behaves. ::
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    if %HideDetails%==Y (
    set flag=/nfl /ndl
    ) ELSE (
    set flag=
    )
    
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: Enable Delayed Expansion and Extensions, and change to the directory where the batch file is located. ::
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    setlocal enabledelayedexpansion
    setlocal enableextensions
    cd /d %~dp0
    
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: Check to see if this batch file is being run as Administrator. If it is not, then rerun the batch file ::
    :: automatically as admin and terminate the intial instance of the batch file.                            ::
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    openfiles > NUL 2>&1 
    if NOT %ERRORLEVEL% EQU 0 (
    powershell.exe start-process '%~f0' -verb runas
    exit
    )
    
    ::::::::::::::::::::::::::::::::::::::::::::::::
    :: End Routine to check if being run as Admin ::
    ::::::::::::::::::::::::::::::::::::::::::::::::
    
    :IsAdmin
    
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: We reach this point once the batch file is run as admin ::
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: Change the console mode to 120 columns wide by 25 lines high ::
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    mode con: cols=120 lines=25
    
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: Ask user for location of mounted ISO image or the directory containing the Windows files. ::
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    cls
    echo Introduction
    echo ============
    echo.
    echo This batch file will create a bootable flash drive from a mounted Windows ISO image or an image extracted to disk.
    echo If you are using an ISO image, mount it before you continue by double-clicking the ISO image and note the drive
    echo letter to which it is mounted.
    echo.
    echo You will be asked if you want to wipe the destination disk or perform a refresh operation. If this is the first
    echo time preparing the disk, use the WIPE option. Be aware that this will destroy ALL data currently on the disk!
    echo.
    echo If you choose the REFRESH option, you will be asked for the drive letter of the two partitions previously
    echo created on the disk. We will then replace the files on these partitions with those from the source that you
    echo specify. This is especially helpful if you create additional partitions on the disk because it will leave
    echo those partitions intact.
    echo.
    pause
    cls
    echo Do you want to perform a WIPE operation or a REFRESH operation?
    echo.
    choice /C WR /N /M "Press W or R to respond:"
    if errorlevel 2 set WipeRefresh=REFRESH & goto GetSourcePath
    if errorlevel 1 set WipeRefresh=WIPE & goto GetSourcePath
    
    :GetSourcePath
    
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: Get the path to the Windows source files.                           ::
    :: Tip: The path can end with or without a backslash (\). For example, ::
    :: either D:, D:\, D:\ISO_Files, D:\ISO_Files\ are all valid paths.    ::
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    cls
    echo Enter the path to the SOURCE where your Windows files are located below.
    echo.
    :GetSourcePath
    set /p SourcePath="Enter source path: "
    
    :: Add a trailing backslash (\) if one does not exist
    
    IF NOT "%SourcePath:~-1%"=="\" (
    set SourcePath=%SourcePath%\
    )
    
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: Any valid Windows boot media will have a file called "boot\bootfix.bin" on the drive. This is true for both ::
    :: single architecture images (x64 or x86) or for images with dual architectures. We will do a simple check to ::
    :: see if such a file exists as a basic test for a valid source image location.                                ::
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    if NOT EXIST %SourcePath%boot\bootfix.bin (
    cls
    echo The location that you specified does not contain a valid Windows image. Please try another location.
    echo If you are specifying a location on disk, please be sure to specify the location to the root of the
    echo Windows image. If you are using an ISO image, you should double-click the ISO image to mount it and
    echo note the drive letter to which it was mounted.
    echo.
    goto GetSourcePath
    )
    
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: The directory structure for a dual architecture image (one that has BOTH x64 and x86 images) will include    ::
    :: \x64 and \x86 folders. In order for us to properly handle this, we need to determine if the source specified ::
    :: is a single of dual architecture image. To do so, we will simply check for the existance on a \x64 folder.   ::
    :: The variable Architecture will be set to either SINGLE or DUAL.                                              ::
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    if exist %SourcePath%\x64 (
    set Architecture=DUAL
    ) ELSE (
    set Architecture=SINGLE
    )
    
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: If a refresh operation was selected, then we need to ask the user for the drive letter associated ::
    :: with the partitions. Otherwise, we need to identify what disk will be wiped.                      ::
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    If %WipeRefresh%==WIPE goto GetDiskNum
    
    :GetPar1Letter
    
    cls
    echo Please enter the drive letter of the FIRST partition (the FAT32 partition) on the disk that we will refresh. Please
    echo enter a drive letter only with no colon (:).
    echo.
    set /P Partition1="Drive letter of FIRST partition: "
    
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: As a safety check, verify that the first partition has a file \boot\bootfix.bin ::
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    if exist %Partition1%:\boot\bootfix.bin goto GetPar2Letter
    cls
    echo ERROR! Either the drive letter you specified does not exist or it does not seem to contain a previously
    echo created partition with suitable Windows installation files.
    echo.
    echo Please verify that you have specified the correct drive letter.
    echo.
    pause
    goto GetPar1Letter
    
    :GetPar2Letter
    
    cls
    echo Please enter the drive letter of the SECOND partition (the exFAT or NTFS partition) on the disk that we will
    echo refresh. Please enter a drive letter only with no colon (:).
    echo.
    set /P Partition2="Drive letter of SECOND partition: "
    
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: As a safety check, verify that the second partition has either a \Sources or a \x64 folder ::
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    if exist %Partition2%:\Sources goto Par2Valid
    if exist %Partition2%:\x64 goto Par2Valid
    
    cls
    echo ERROR! Either the drive letter you specified does not exist or it does not seem to contain a previously
    echo created partition with suitable Windows installation files.
    echo.
    echo Please verify that you have specified the correct drive letter.
    echo.
    pause
    goto GetPar2Letter
    
    :Par2Valid
    
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: Since we are performing a refresh operation, there is no need for us to get a disk number. We will ::
    :: skip that and proceed to the summary screen.                                                       ::
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    goto Summary
    
    :GetDiskNum
    
    :::::::::::::::::::::::::::::::::::::::::::::::::
    :: Display a list of disks seen by the system. ::
    :::::::::::::::::::::::::::::::::::::::::::::::::
    
    cls
    (echo list disk
    echo exit
    ) | diskpart
    
    echo.
    echo Above is a list of disks connected to your system. Scroll up if the list is too long.
    echo CAUTION: *MAKE SURE* that you specify the correct disk because it will be erased. Press CTRL-C to abort.
    echo.
    set /p DiskID="Enter the disk number for the DESTINATION disk (Enter only the number and press ENTER): "
    
    if [%DiskID%] EQU [] Goto GetDiskNum
    
    :Summary
    
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: Display a summary of options that will be used and get confirmation ::
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    cls
    echo Summary of options you have selected:
    echo.
    
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: These summary items apply to both WIPE and REFRESH operations ::
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    echo Path for the source files: %SourcePath%
    
    if %HideDetails%==Y (
    echo File copy status details WILL NOT be displayed
    ) ELSE (
    echo File copy status details WILL be displayed
    )
    
    
    
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: The summary items below apply only to WIPE operations, so if a ::
    :: REFRESH is being performed, skip this section                  ::
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    if %WipeRefresh%==REFRESH goto RefreshSummary
    
    echo Drive number to make bootable: %DiskID%
    echo Partition type: %PartType%
    echo Partition 1 size: %Partition1Size% MB
    echo Partition 2 filesystem type: %Part2FS%
    
    if NOT %Part2SizeLimit%==N (
    echo Partition 2 size: %Part2SizeLimit% MB
    ) ELSE (
    echo Partition 2 size: Use all remaining space
    )
    
    echo Partition 1 volume label: %Partition1Name%
    echo Partition 2 volume label: %Partition2Name%
    
    goto GetConfirmation
    
    :RefreshSummary
    
    ::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: These items apply only to a REFRESH operation. ::
    ::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    echo Drive letter of FIRST partition to refresh: %Partition1%:
    echo Drive letter of SECOND partition to refresh: %Partition2%:
    
    :GetConfirmation
    
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: Time to get final confirmation from user. If the user does not confirm ::
    :: that everything is correct, show some possible resolutions.            ::
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    echo.
    choice /C YN /N /M "Is this correct? (Press Y or N to respond):"
    if errorlevel 2 (
    cls
    echo.
    echo        Symptom                                            Corrective Action
    echo        =======                                            =================
    echo Source path is wrong:                 Run the program again and respond with the correct path
    echo Wrong drive number for a WIPE:        Run the program again and respond with the correct drive number
    echo Wrong drive letters for a REFRESH:    Run the program again and respond with the correct drive letters
    echo File copy status display incorrect:   Change the setting of "HideDetails" at start of program
    echo Wrong partition sizes:                Change the setting of "Partition1Size" or "Part2SizeLimit" at start of program
    echo Wrong volume labels for a WIPE:       Change the setting of "Partition1Name" or "Partition2Name" at start of program
    echo Wrong partition type:                 Change the setting of "PartType" at start of program
    echo.
    pause
    exit
    )
    
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: We are creating 2 partions. A FAT32 partition and an exFAT or NTFS partition. We only need the sources   ::
    :: folder on the exFAT or NTFS partition. On the FAT32 partition, we want everything else. We also want the ::
    :: single file called BOOT.WIM in the sources folder on the FAT32 partition.                                ::
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    cls
    if %WipeRefresh%==WIPE echo We are partitioning the destination drive and copying files.
    if %WipeRefresh%==REFRESH echo We are formatting drives %Partition1%: and %Partition2%:	and copying files. Other partitions will be left alone.
    echo Please be patient^^! This can take a while especially if your drive is slow.
    echo.
    
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: If we are performing a REFRESH, then there are a lot of steps that we can skip. ::
    :: As a result, we will skip to the CopyOperations section.                     ::
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    if %WipeRefresh%==REFRESH goto CopyOperations
    
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: We will first wipe the selected disk. This will free up any drive letters currently used by that disk. ::
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    (echo select disk %DiskID%
    echo clean
    echo convert %PartType%
    echo rescan
    echo exit
    ) | diskpart > nul
    
    ::::::::::::::::::::::::::::::::::::::::::::::::
    :: Determine the first available drive letter ::
    ::::::::::::::::::::::::::::::::::::::::::::::::
    
    for %%a in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do if not exist %%a:\nul (
    set Partition1=%%a
    goto DriveLetter1Found
    )
    :DriveLetter1Found
    
    echo The first partition will be assigned drive letter %Partition1%: and will be formatted with FAT32.
    
    (echo select disk %DiskID%
    echo create partition primary size=%Partition1Size%
    echo select partition 1
    echo format fs=fat32 quick
    echo assign letter=%Partition1%
    echo active
    echo rescan
    echo exit
    ) | diskpart > nul
    
    :::::::::::::::::::::::::::::::::::::::::::::::
    :: Determine the next available drive letter ::
    :::::::::::::::::::::::::::::::::::::::::::::::
    
    for %%a in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do if not exist %%a:\nul (
    set Partition2=%%a
    goto DriveLetter2Found
    )
    :DriveLetter2Found
    echo The second partition will be assigned drive letter %Partition2%: and will be formatted with %Part2FS%.
    echo.
    
    if %Part2SizeLimit%=="N" goto NoSizeLimit
    
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: User has elected to create the second partition with a specific size ::
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    (echo select disk %DiskID%
    echo create partition primary size=%Part2SizeLimit%
    echo format fs=%Part2FS% quick
    echo assign letter=%Partition2%
    echo rescan
    echo exit
    ) | diskpart > nul
    
    :NoSizeLimit
    
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: User has elected create the second partition with all remaining space ::
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    (echo select disk %DiskID%
    echo create partition primary
    echo format fs=%Part2FS% quick
    echo assign letter=%Partition2%
    echo rescan
    echo exit
    ) | diskpart > nul
    
    :PartitionsCreated
    
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: Set volume labels on the two partitions that we just created. ::
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    label %Partition1%:%Partition1Name%
    label %Partition2%:%Partition2Name%
    
    :CopyOperations
    
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: This section is for the copy operations from SOURCE to DESTINATION ::
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: Technical Notes:                                                                                                 ::
    ::                                                                                                                  ::
    :: Some flash drives present themselves as a fixed disk and as a result they my have a recyle bin folder on them.   ::
    :: are excluding the system folders which includes the recycle bin from the following operation. The /njh and /njs  ::
    :: switches prevent robocopy from displaying the header and summary information. If you want to stop robocopy from  ::
    :: displaying file copy progress just add a /nfl /ndl (No File Listing and No Directory Listing) to each robocopy   ::
    :: command. Note that if the user elected to hide details of the copy operation, then the variable "flag" will be   ::
    :: set to "/nfl /ndl" which will hide the directory and file listings.                                              ::
    ::                                                                                                                  ::
    :: For reasons unknown to me, sometimes a path enclosed in quotes does not work in robocopy unless you add a        ::
    :: trailing space. In the below commands I found this to be true only on the first robocopy command but I've added  ::
    :: the space to all commands for consistency. We need the quotes just in case a path with spaces in the name is     ::
    :: specified.                                                                                                       ::
    ::                                                                                                                  ::
    :: It was previously necessary to create a file named ei.cfg in the \Sources foler. Technically, this file is only  ::
    :: needed if you are NOT using an AUTOUNATTEND.XML answer file, but it won't hurt to have it there anyway. However, ::
    :: in my testing, it seems that this file is no longer necessary. As a result, the code to create that file is      ::
    :: commented out below but I have not removed it just in case it is needed again.                                   ::
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    if %Architecture%==DUAL goto DualArchitecture
    
    :: Copying files to the FAT32 partition
    
    robocopy "%SourcePath% " %Partition1%:\ /mir /xd sources "system volume information" $recycle.bin /njh /njs %flag%
    robocopy "%SourcePath%sources " %Partition1%:\sources boot.wim /njh /njs %flag%
    
    :: Copying files to the exFAT or NTFS partition
    
    robocopy "%SourcePath%sources " %Partition2%:\sources /mir /njh /njs /xf boot.wim %flag%
    robocopy %Partition1%:\ %Partition2%:\ /mov autounattend*.xml %flag%
    
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: Technical note: It was previously necessary to create a file named ei.cfg in the \Sources foler. Technically,  ::
    :: this file is only needed if you are NOT using an AUTOUNATTEND.XML answer file, but it won't hurt to have it    ::
    :: there anyway. However, in my testing, it seems that this file is no longer necessary. As a result, the code to ::
    :: create that file is commented out below but I have not removed it just in case it is needed again.             ::
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    :: echo [CHANNEL] > %Partition2%:\sources\ei.cfg
    :: echo Retail >> %Partition2%:\sources\ei.cfg
    
    goto DoneCopying
    
    :DualArchitecture
    
    :: Copying files to the FAT32 partition
    
    robocopy "%SourcePath% " %Partition1%:\ /mir /xd sources x64 x86 "system volume information" $recycle.bin /njh /njs %flag%
    robocopy "%SourcePath%x64\sources " %Partition1%:\x64\sources boot.wim /njh /njs %flag%
    robocopy "%SourcePath%x86\sources " %Partition1%:\x86\sources boot.wim /njh /njs %flag%
    
    :: Copying files to the exFAT or NTFS partition
    
    robocopy "%SourcePath%x64\sources " %Partition2%:\x64\sources /mir /njh /njs /xf boot.wim %flag%
    robocopy "%SourcePath%x86\sources " %Partition2%:\x86\sources /mir /njh /njs /xf boot.wim %flag%
    robocopy %Partition1%:\ %Partition2%:\ /mov autounattend*.xml %flag%
    
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: Technical note: It was previously necessary to create a file named ei.cfg in the \Sources foler. Technically,  ::
    :: this file is only needed if you are NOT using an AUTOUNATTEND.XML answer file, but it won't hurt to have it    ::
    :: there anyway. However, in my testing, it seems that this file is no longer necessary. As a result, the code to ::
    :: create that file is commented out below but I have not removed it just in case it is needed again.             ::
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    :: echo [CHANNEL] > %Partition2%:\x64\sources\ei.cfg
    :: echo Retail >> %Partition2%:\x64\sources\ei.cfg
    
    :: echo [CHANNEL] > %Partition2%:\x86\sources\ei.cfg
    :: echo Retail >> %Partition2%:\x86\sources\ei.cfg
    
    :DoneCopying
    
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: Inform the user that we are done. Also, as a precaution, check to see if an ::
    :: unattended setupanswer file is present and warn the user if it is.          ::
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    cls
    echo All operations have been completed.
    echo.
    
    if exist %Partition2%:\autounattend.xml (
    echo ^^!CAUTION^^! An unattended setup file ^(autounattend.xml^) is present on the 2nd partition.
    echo As a result, if you boot from this disk, an unattended installation will begin. This has
    echo the potential to wipe out the contents of disks attached to your system without warning.
    echo.
    )
    pause
    
    :END
    
    exit
      My Computers


  5. Posts : 17,278
    Windows 11 Pro
       #5

    Have you tried plugging the USB flash drive into a black USB 2.0 port on the back of the motherboard?
      My Computer


  6. Posts : 3,987
    Windows 7 HP 64 - Windows 10 Pro - Lubuntu
       #6

    To make a win 10 USB drive boot able

    Open a CMD window as administrator and type:
    diskpart
    list disk (it will list all drives. Identify the USB drive number)
    select disk n (replace n by the USB drive number obtained with list disk)
    clean
    convert mbr
    create part primary
    select part 1
    format fs=fat32 quick
    assign
    active
    exit (to exit diskpart)

    Mount the Win10 installation iso file and copy all files and folders to root of the USB drive

    Installation
    Reset BIOS or load defaults.
    Set Disk mode to AHCI, not RAID
    Disable fast boot and secure boot (you can turn it on after installation)

    Windows can be installed in two ways: Legacy-MBR or UEFI-GPT
    To install as Legacy-MBR you must boot the installation drive as Legacy
    To install as UEFI-GPT you must boot the installation drive as UEFI.

    As you have a new MB, you should install as UEFI-GPT (if you have already installed Linux on the drive you must install the same type (Legacy-MBR or UEFI-GPT).

    Detach any other drives (SATA or Power cable) from the MB.
    On BIOS, disable fast boot and secure boot (you can enable after installation)

    During POST, press F12 to launch the boot menu. You will see two options for the USB drive. USB UEFI (Name) and USB (Name). Select USB UEFI (Name).
    Go to install and select the unallocated space on the SSD and then proceed.
    If you don't want to use MS account, don't enable updates or connect to the internet during installation.
      My Computers


  7. Posts : 8
    Win 10
    Thread Starter
       #7

    NavyLCDR said:
    Have you tried plugging the USB flash drive into a black USB 2.0 port on the back of the motherboard?
    I did, that was one of my first thoughts too.
      My Computer


  8. Posts : 2,773
    Windows 11 Pro, 21H2
       #8

    Yeah, it wouldn't be the USB port. From you described earlier it sounds like it started booting successfully and then failed. If it even starts, it's not the USB port.

    However, humor me - did you try the script I provided? It's entirely possible it may not work but I have very good reason to want to try it.
      My Computers


  9. Posts : 8
    Win 10
    Thread Starter
       #9

    hsehestedt said:
    Yeah, it wouldn't be the USB port. From you described earlier it sounds like it started booting successfully and then failed. If it even starts, it's not the USB port.

    However, humor me - did you try the script I provided? It's entirely possible it may not work but I have very good reason to want to try it.
    Not yet, the machine in question is at work. I'll try it out tomorrow. I'll be sure to post the results.

    - - - Updated - - -

    Win 10 USB install Fails, Linux has no problem-error_1.jpg
    E:\ is the iso
    Disk 2 is the Thumb Drive.
    It begins to wipe it, and after it does it loses sight of the drive (changes from drive F: to D:) then errors out.
      My Computer


  10. Posts : 16,017
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
       #10

    Hello @Bytebait,

    I have NOT had time to look through the code, but you have set BOTH Partitions to D:\, as per your screenshot!

    There should be TWO separate Partitions, one formatted as FAT32, and the other formatted as NTFS.

    I hope this helps.
      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 20:00.
Find Us




Windows 10 Forums