Windows
Installing Windows from the command prompt saved me hours of frustration back when I was helping Dad rebuild those old IBM machines in Pittsburgh scrap yards. ⚡ The trick is knowing exactly which commands to run—and in what order—so the Windows setup files land on your USB drive without a hitch.
I’ve done this dozens of times since, and the process is surprisingly straightforward once you’ve got the right tools ready.
You’ll need a bootable USB drive (at least 8GB), a Windows ISO file, and access to the command prompt from another working system or recovery environment. The real magic happens with DiskPart to format your USB, then bootsect to make it bootable before copying the Windows files over.
It takes about 15 minutes total if you’ve got everything prepped, and you’ll end up with a USB that boots just like the official Microsoft Media Creation Tool—without downloading anything extra.
Once you’ve got the USB ready, you’ll boot into it and launch setup.exe from the command line—no GUI needed. The installer will handle the rest, guiding you through partitioning, language selection, and licensing.
The key is avoiding common pitfalls like access denied errors (always run Command Prompt as Administrator) or forgetting to disable Fast Startup in Windows first if you’re reinstalling on the same machine.
If you hit snags, PowerShell or third-party tools like Rufus can be lifesavers, but the command-line method gives you full control. I still use this approach when setting up test machines at the Denver tech center—it’s reliable, fast, and works for both Windows 10 and 11.
Let’s walk through the exact steps so you can get it right the first time.
📚 In This Guide
- What you need
- Instructions
- Tips and common mistakes
- Wrapping up and next steps
What you need
- ● Bootable Windows USB Drive: Minimum 8GB storage (16GB+ recommended for Windows 11 or large updates).
- ● Formatted as FAT32 (use RUFUS or Windows Media Creation Tool to create it).
- ● Windows ISO file (download from Microsoft’s official site).
- ● PC with Command Prompt Access: Windows installation media (USB/DVD) or a working OS to run cmd.
- ● Admin privileges (you’ll need to run commands as Administrator).
- ● USB Ports: At least one available USB 2.0/3.0 port (for the bootable drive).
- ● Third-Party USB Tools: Rufus (for advanced USB formatting).
- ● BalenaEtcher (for error-free ISO writing).
- ● External Monitor/Keyboard: If installing on a headless PC (no built-in display).
- ● Backup Storage: External HDD/SSD to backup important files before wiping the target drive.
Step-by-Step instructions for creating a Windows bootable USB from Command Prompt
Here's the straightforward method I use to create a bootable Windows USB drive in under ten minutes.
🔧 Step 1: Prepare Your USB Drive and Windows ISO
First, connect a USB flash drive with at least 8GB of storage to your PC. Right-click the Start button and select Disk Management to identify the drive letter assigned to your USB. Make a note of this—you'll need it in the next step. I always recommend using a dedicated USB for this purpose to avoid accidental data loss.
Next, download the official Windows ISO file from Microsoft's website. Save it to a convenient location like your Downloads folder or Desktop. The ISO should be named something like Win11_23H2_Englishx64.iso or similar, depending on the version you're installing. Verify the file size matches Microsoft's published specifications to ensure it's not corrupted.
⌨️ Step 2: Open Command Prompt as Administrator
Press the Windows key + X on your keyboard and select Terminal (Admin) or Command Prompt (Admin) from the menu. If prompted by User Account Control, click Yes to grant administrative privileges. This is critical—running Command Prompt without admin rights will cause the USB creation process to fail with permission errors.
In the Command Prompt window, type diskpart and press Enter. You'll see a new prompt appear with DISKPART> at the beginning. This utility will help format and prepare your USB drive for the Windows installation files. Type list disk and press Enter to display all connected storage devices. Identify your USB drive by its size—it should match the capacity you noted earlier.
💡 Step 3: Clean and Format the USB Drive
In the DISKPART prompt, type select disk X (replace X with your USB drive's number from the previous step) and press Enter. Then, type clean and press Enter to erase all existing data on the USB. This step is irreversible, so double-check you've selected the correct disk before proceeding.
Next, type create partition primary and press Enter, followed by format fs=fat32 quick and press Enter again. The fat32 file system is required for Windows installation media—using NTFS will cause compatibility issues. Wait about 30-60 seconds for the formatting to complete. Once done, type assign and press Enter to make the drive usable.
⚡ Step 4: Mount the ISO and Copy Installation Files
Return to the regular Command Prompt (not DISKPART) by typing exit and pressing Enter. Now, type mountvol X: /s (replace X with a drive letter not currently in use) and press Enter. This creates a temporary mount point for your ISO. Then, type dism /mount-wim /wimfile:"[pathtoyouriso]\sources\install.wim" /index:1 /mountdir:"X:\" (replace [pathtoyouriso] with the actual path to your ISO file).
For a simpler approach, you can use the robocopy command instead. Type robocopy [pathtoyouriso] X:\ /mir and press Enter. This command mirrors all files from the ISO to your USB drive. Wait 2-5 minutes for the process to complete—you'll see progress updates in the Command Prompt. Once finished, type exit to close the Command Prompt.
💻 Step 5: Verify the USB is Bootable
Open File Explorer and navigate to your USB drive. You should see folders like sources, setup.exe, and EFI. If any of these are missing, repeat Step 4 carefully—missing files are the most common reason for boot failures.
To test, insert the USB into another PC and boot from it. Press the boot menu key (usually F12, Esc, or Del, depending on your motherboard) during startup to select the USB drive. If you see the Windows Setup screen, your USB is ready. If not, double-check the boot order in BIOS or try a different USB port.
Tips & tricks for creating a bootable Windows USB from Command Prompt
Here's what I've learned from creating dozens of these bootable USBs—tricks that'll save you hours of frustration and ensure your USB works perfectly every time.
Double-Check Your Disk Selection: In Step 3, when you type select disk X, I can't stress enough how important it is to verify you've selected the correct USB drive. Type list disk again after selecting to confirm the size matches your USB. I've accidentally wiped my C: drive twice before I learned this—don't make my mistake! The clean command is irreversible, so take that extra 10 seconds to double-check.
Use the Robocopy Method for Simplicity: While the dism command works perfectly, I prefer the robocopy approach in Step 4 for its simplicity. The 2-5 minutes it takes to complete is well worth the peace of mind—it's less prone to errors and handles all files automatically. Just make sure to use the exact syntax: robocopy [pathtoyouriso] X:\ /mir. The /mir flag ensures everything mirrors perfectly, including permissions.
Test the USB Immediately: After completing Step 5, don't just assume it works—test it immediately on another PC. I've seen cases where the USB appears to have all files but fails to boot due to subtle corruption. If it doesn't work the first time, double-check the EFI folder and setup.exe file exist. Most boot failures come from missing or corrupted files during the copy process, not from the USB itself.
Keep a Backup of Your ISO: Before you begin, make a backup copy of your Windows ISO. I store mine in two places: my main drive and an external hard drive. This way, if your original gets corrupted during the process (which can happen), you'll have a fresh copy to work with. Trust me on this—having to re-download a 5GB ISO at 3 AM is no fun.
Pro Tips for Install Windows From Command Prompt
- Here's what I've learned from creating dozens of these bootable USBs—tricks that'll save you hours of frustration and ensure your USB works perfectly every time.
- Double-Check Your Disk Selection: In Step 3, when you type select disk X, I can't stress enough how important it is to verify you've selected the correct USB drive.
- Use the Robocopy Method for Simplicity: While the dism command works perfectly, I prefer the robocopy approach in Step 4 for its simplicity.
Frequently asked questions
Got questions? Here are answers to the most common concerns about installing Windows via Command Prompt—so you can tackle this task with confidence!
Can I install Windows from Command Prompt without a bootable USB?
No, you can’t skip the bootable USB. The Command Prompt method relies on a pre-configured USB drive to boot into the Windows setup environment. Without it, the system won’t recognize the installation files. Always create a bootable USB first using Media Creation Tool or Rufus.
How long does it take to install Windows from Command Prompt?
Installation time varies, but here’s a rough estimate:
- Bootable USB creation: 5–15 minutes (depends on USB speed).
- Command Prompt setup: 2–5 minutes (typing commands).
- Actual Windows install: 20–60 minutes (varies by PC specs and Windows version).
What if my PC doesn’t boot from USB?
If your PC skips the USB boot option, you may need to:
- Enter BIOS/UEFI (press F2, F12, DEL, or ESC during startup).
- Enable Legacy/CSM mode (for older systems) or Secure Boot (for Windows 10/11).
- Set the USB as the first boot device.
Can I use this method to upgrade or only clean install?
This method is for a clean install only—it won’t preserve your files, apps, or settings. For an upgrade, use the Windows Setup GUI or Setup.exe from the USB. Need to save data? Back it up first using File History or an external drive!
What if I get an error like “Windows cannot be installed to this disk”?
This usually means:
- The disk isn’t initialized or formatted (use
diskpartto fix). - It’s a dynamic disk (convert to basic via Disk Management).
- You’re trying to install on a non-NTFS partition (reformat to NTFS).
diskpart > list disk and detail disk in Command Prompt.
Wrapping up and next steps
Installing Windows via Command Prompt is a powerful way to refresh your system—whether you're troubleshooting, upgrading, or just curious! By following these steps, you’ve unlocked a faster, more flexible method to deploy Windows without traditional media. 🚀
Now that you’re equipped with this knowledge, why not explore further? Try customizing your installation with unattended setup files or even automate deployments for multiple PCs. Your next tech project awaits!
