Skip to content

Instantly share code, notes, and snippets.

@Alee14
Last active April 26, 2024 13:21
Show Gist options
  • Star 18 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Alee14/e8ce6306a038902df6e7a6d667544ac9 to your computer and use it in GitHub Desktop.
Save Alee14/e8ce6306a038902df6e7a6d667544ac9 to your computer and use it in GitHub Desktop.
Installing Windows using CMD. (UEFI and BIOS Supported)

Installing Windows using CMD. (UEFI and BIOS Supported)

Guide created by Andrew Lee

Note that this guide does not go into detail, it's just providing the commands to install Windows.

Be cautions when doing this when dualbooting, please backup any existing data or you will lose them all.

Open CMD

First open CMD by pressing the following keys after booting into setup: Shift + F10

Creating Partition

MBR

diskpart
list disk
select disk (number for main disk)
clean # Clearing the partitions
convert mbr
-----------------------
(Creating recovery is optional)
create part primary size 500
format quick label Recovery
assign letter R
set id 27
-----------------------
create part primary
format quick label Windows (or label of your choice)
assign letter C (or E)
active
exit

UEFI

diskpart
list disk
select disk (number for main disk)
clean # Clearing the partitions
convert gpt
create part efi size 512
format fs fat32 quick
assign letter w
create part msr size 16
-----------------------
(Creating recovery is optional)
create part primary size 500
format quick label Recovery
assign letter R
set id de94bba4-06d1-4d40-a16a-bfd50179d6ac
gpt attributes 0x8000000000000001
-----------------------
create part primary 
format quick label Windows (or label of your choice)
assign letter C (or E)
exit

Go to install.wim directory

[letter of installation disk]:
cd sources

List SKUs

Listing SKUs like Home, Pro, Education, Ultimate, etc.

dism /get-wiminfo /wimfile:[Location to install.wim]

Deploying WIM file

Copies the content from the install.wim file to the main disk.

dism /apply-image /imagefile:[Location to install.wim] /index:[SKU Number] /applydir:(Drive letter to main disk)

e.g dism /apply-image /imagefile:d:\sources\install.wim /index:6 (Win10 Pro) /applydir:C:\

Creating recovery folders and copying Windows RE to the recovery partition (Optional)

md R:\Recovery
xcopy /h C:\Windows\System32\Recovery\Winre.wim R:\Recovery
C:\Windows\System32\Reagentc /Setreimage /Path R:\Recovery /Target C:\Windows

Creating boot files

MBR only

bootsect /nt60 C: (or E:) /force /mbr

MBR + UEFI

bcdboot (Drive letter to main disk):\Windows

Add argument if it's UEFI (if needed)

/s [drive letter to UEFI]:

Bypassing the OOBE entirely (Optional)

reg load HKLM\SOFT C:\Windows\System32\config\SOFTWARE
reg load HKLM\SYS C:\Windows\System32\config\SYSTEM
reg add HKLM\SOFT\Microsoft\Windows\CurrentVersion\Policies\System /v VerboseStatus /t REG_DWORD /d 1 /f
reg add HKLM\SOFT\Microsoft\Windows\CurrentVersion\Policies\System /v EnableCursorSuppression /t REG_DWORD /d 0 /f
reg add HKLM\SYS\Setup /v CmdLine /t REG_SZ /d cmd.exe /f

Reboot

wpeutil reboot

Bypassing the OOBE entirely (P2)

Run Windows Deployment Loader then enable recovery

oobe\windeploy
Reagentc /enable (if you made a recovery parition)
Reagentc /Info /Target C:\Windows

Add user (When the boot status says "Getting Ready")

net user /add (username) (password)
net localgroup users /add (username) # in case Windows didn't add the users group
net localgroup administrators /add (username)

Clear OOBE status

reg add HKLM\SYSTEM\Setup /v OOBEInProgress /t REG_DWORD /d 0 /f
reg add HKLM\SYSTEM\Setup /v SetupType /t REG_DWORD /d 0 /f
reg add HKLM\SYSTEM\Setup /v SystemSetupInProgress /t REG_DWORD /d 0 /f
exit

Disabling VerboseStatus and Enabling CursorSuppression (Optional)

When entering the desktop open CMD as admin and run the following.

reg add HKLM\SOFT\Microsoft\Windows\CurrentVersion\Policies\System /v VerboseStatus /t REG_DWORD /d 0 /f
reg add HKLM\SOFT\Microsoft\Windows\CurrentVersion\Policies\System /v EnableCursorSuppression /t REG_DWORD /d 1 /f

Credits

If there's anything that needs to be added, feel free to tell me in the comments below!

  • Caesar (TheDarkBomber#0229): For helping fixing some things in the script that I forgot or needed to add.
@Skeeterskoot
Copy link

Would this bypass a boot virus I got I can't seem to get rid of it it uses windows and their credentials it was made with ubuntu

@Alee14
Copy link
Author

Alee14 commented Jan 5, 2024

Would this bypass a boot virus I got I can't seem to get rid of it it uses windows and their credentials it was made with ubuntu

If you were to do a reinstall, yes. But all your data will be wiped and would require data recovery to restore those files. Though I would not recommend using this guide to fix your issue and should probably seek a better guide on dealing with your issue.

@kenzieshaneGD
Copy link

Error: 193
An error occurred. DISM could not be initialized in the local folder. Ensure that DISM is installed correctly and that all of the binary are present.

Why does issues arise after I installed Ubuntu 😭

@Alee14
Copy link
Author

Alee14 commented Apr 17, 2024

Error: 193
An error occurred. DISM could not be initialized in the local folder. Ensure that DISM is installed correctly and that all of the binary are present.

Seems like a corrupted system file, though this is not the place to troubleshoot issues regarding Windows itself.

@kenzieshaneGD
Copy link

okay I found out the answer to my problem

Ventoy can't really open the newest Windows 10.iso v1 English;even it throws a BCD file not found error when booted without .win mode

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment