Automate diskpart for Clean Install.

Page 2 of 2 FirstFirst 12

  1. Posts : 7,606
    Windows 10 Home 20H2
       #11

    You can run DiskPart from a bootable USB device.

    Create Bootable USB Flash Drive to Install Windows 10

    You can also run DiskPart from a WinPE device.
      My Computer


  2. Posts : 13,896
    Win10 Version 22H2 Pro and Home, Win11 Pro and Home
       #12

    True but I didn't get that from the post, must'a missed it.
      My Computers


  3. Posts : 4,131
    Windows 3.1 to Windows 11
       #13

    actually you really do not want to Pre-Assign drive letter "C" (thus I used "W") as "C" will automatically be assigned to the OS partition when booted... DiskPart is embedded into PE....

    As there is more to it - to set ID & Hide the system and system image partition...
    Code:
    rem === HideRecoveryPartitions-BIOS.txt ===
    select disk 0
    select partition 1
    set id=17
    remove
    select partition 4
    set id=27
    remove
    list volume
    exit
    Code:
    @echo == ApplyImage.bat ==
    @echo.
    @echo    These commands deploy a specified Windows
    @echo    image file to the Windows partition, and configure
    @echo    the system partitions.
    @echo.
    @echo    Usage:   ApplyImage WimFileName 
    @echo    Example: ApplyImage D:\Install.wim
    @echo.
    @echo    Applying the image to the Windows partition
    dism /Apply-Image /ImageFile:%1 /Index:1 /ApplyDir:W:\
    @echo.
    @echo    Copying boot files to the System partition ==
    W:\Windows\System32\bcdboot W:\Windows /s S:
    @echo.
    @echo    Copying the Windows RE image to the
    @echo    Windows RE Tools partition
    md R:\Recovery\WindowsRE
    xcopy /h W:\Windows\System32\Recovery\Winre.wim R:\Recovery\WindowsRE\
    You can drop install.wim on Deploy.bat - and the full deployment will be automated - CreatePartition - Apply Image - Hide Partitions - Although contains both MBR & UEFI deployment with Boot Detection
    Code:
    @cls
    @echo **********************************************************************
    @echo   Deploy.bat
    @echo   Note: Run from the reference device in the WinPE environment
    @echo.
    @echo.
    @if %1x==x echo Re-run this program with a path to a WIM file, example:
    @if %1x==x echo Deploy.bat D:\install.wim
    @if %1x==x goto END
    @echo.
    @echo.
    @echo   Detecting the firmware mode (BIOS or UEFI). 
    @echo   Note: Some PCs may support both modes. 
    @echo         Verify you're booted into the correct mode before proceeding: 
    wpeutil UpdateBootInfo
    for /f "tokens=2* delims=     " %%A in ('reg query HKLM\System\CurrentControlSet\Control /v PEFirmwareType') DO SET Firmware=%%B
    @echo         Note: delims is a TAB followed by a space.
    @echo.
    if %Firmware%==0x1 echo Detected firmware mode: BIOS.
    if %Firmware%==0x2 echo Detected firmware mode: UEFI.
    @echo   If this is correct, press a key to continue. 
    @echo.
    @echo   If this is NOT correct: Press Ctrl+C to exit this script.
    @echo         Type exit to reboot the PC, and then
    @echo         boot the USB key using the correct firmware mode. @pause
    @echo **********************************************************************
    @echo.
    @echo   Partition and format the disk
    @echo   CAUTION: All the data on the primary disk will be DELETED.
    pause
    if %Firmware%==0x1 diskpart /s %~dp0CreatePartitions-BIOS.txt
    if %Firmware%==0x2 diskpart /s %~dp0CreatePartitions-UEFI.txt
    pause
    @echo.
    @echo.
    @echo **********************************************************************
    @echo.
    @echo.
    @echo    Applying image
    call %~dp0ApplyImage %1
    pause
    @echo
    @echo
    @echo **********************************************************************
    @echo.
    @echo    Hiding the recovery tools partition
    @echo.
    @echo.
    if %Firmware%==0x1 diskpart /s %~dp0HideRecoveryPartitions-BIOS.txt
    if %Firmware%==0x2 diskpart /s %~dp0HideRecoveryPartitions-UEFI.txt
    @echo.
    @echo.
    @echo **********************************************************************
    @echo   All done!
    @echo   Disconnect the USB drive from the reference device.
    @echo. @pause
    exit
    :END
      My Computer


  4. Posts : 18,044
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
    Thread Starter
       #14

    Thank you so much everyone for your replies and advice, it is appreciated.

    I am going to mark this thread as Solved. I will spend some time over the next week investigating and getting my head around the code. I will probably initially setup the Disk as normal and then after the installation has completed use MiniTool Partition Wizard for the other Partitons.

    I will dig out an old HDD [ I must have one somewhere ] and try out the above.

    Thanks again.

      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 21:33.
Find Us




Windows 10 Forums