First off, let me say I am NOT a programmer by any means, just doing this for fun and to learn. I would like to put together a diskpart script to format a multi-partition flash drive to use for installing Windows 11. I know about Rufus, Ventoy and other programs which can do this but I want to learn by doing it myself. Basically, I'm going to have the first partition formatted as FAT32 with the boot files necessary to get to the installation screens. The second partition will be formatted using NTFS and hold all the data from the ISO. The first partition will have the folders boot and efi and files bootmgr and bootmgr.efi along with a "sources" folder containing only boot.wim, the second partition will have the entire ISO copied to it. I have created a flash drive manually using the above setup and it works perfectly. Here's the question: Since the flash drive will be a different disk number for each of my computers, can I add something at the beginning of the script that asks me for the disk number each time? These are the lines that will go into the script so far, just want to automate it if possible before calling the script, without having to enter the lines myself: select disk x clean convert mbr create partition primary size=1024 format fs=fat32 quick label=BOOT active assign create partition primary format fs=ntfs quick label=SYSTEM assign exit
Disk part have option list disk And if you want, you can do it with ps That in this case also have options to view drive info So you can filter usb drive alternative implementation No args, script run disk part list disk Than using parameters , pass disk ID
Yes! I did some more research online and found this batch file (made some modifications to suit what I needed): Would be nice to be presented with a list of drives but I'm just not that good LOL!!! I also learned how to inject the bypass registry keys manually into boot.wim so I'm learning a little every day! Code: @echo off set /p "DiskNum=Enter the Disk Number: " ( echo SELECT DISK %DiskNum% echo CLEAN echo CREATE PARTITION PRIMARY SIZE=1024 echo FORMAT FS=FAT32 QUICK LABEL=BOOT echo ASSIGN echo ACTIVE echo CREATE PARTITION PRIMARY echo FORMAT FS=NTFS QUICK LABEL=ISO echo ASSIGN ) > diskpart_script.txt diskpart /s diskpart_script.txt del diskpart_script.txt