Skip to content

Instantly share code, notes, and snippets.

@soham2008xyz
Created September 29, 2024 19:10
Show Gist options
  • Save soham2008xyz/826d8d8a3d94968eee0013eee00886c8 to your computer and use it in GitHub Desktop.
Save soham2008xyz/826d8d8a3d94968eee0013eee00886c8 to your computer and use it in GitHub Desktop.
Install Windows 10/11 from the Command Prompt
rem == ApplyImage.bat ==
rem == These commands deploy a specified Windows
rem image file to the Windows partition, and configure
rem the system partition.
rem Usage: ApplyImage WimFileName
rem Example: ApplyImage E:\Images\ThinImage.wim ==
rem == Set high-performance power scheme to speed deployment ==
call powercfg /s 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
rem == Apply the image to the Windows partition ==
dism /Apply-Image /ImageFile:%1 /Index:1 /ApplyDir:W:\
rem == Copy boot files to the System partition ==
W:\Windows\System32\bcdboot W:\Windows /s S:
:rem == Copy the Windows RE image to the
:rem Windows RE Tools partition ==
md R:\Recovery\WindowsRE
xcopy /h W:\Windows\System32\Recovery\Winre.wim R:\Recovery\WindowsRE\
:rem == Register the location of the recovery tools ==
W:\Windows\System32\Reagentc /Setreimage /Path R:\Recovery\WindowsRE /Target W:\Windows
:rem == Verify the configuration status of the images. ==
W:\Windows\System32\Reagentc /Info /Target W:\Windows
rem == CreatePartitions-UEFI.txt ==
rem == These commands are used with DiskPart to
rem create four partitions
rem for a UEFI/GPT-based PC.
rem Adjust the partition sizes to fill the drive
rem as necessary. ==
select disk 0
clean
convert gpt
rem == 1. System partition =========================
create partition efi size=100
rem ** NOTE: For Advanced Format 4Kn drives,
rem change this value to size = 260 **
format quick fs=fat32 label="System"
assign letter="S"
rem == 2. Microsoft Reserved (MSR) partition =======
create partition msr size=16
rem == 3. Windows partition ========================
rem == a. Create the Windows partition ==========
create partition primary
rem == b. Create space for the recovery tools ===
rem ** Update this size to match the size of
rem the recovery tools (winre.wim)
rem plus some free space.
shrink minimum=500
rem == c. Prepare the Windows partition =========
format quick fs=ntfs label="Windows"
assign letter="W"
rem === 4. Recovery partition ======================
create partition primary
format quick fs=ntfs label="Recovery"
assign letter="R"
set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac"
gpt attributes=0x8000000000000001
list volume
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment