Asked by:
Make bootable usb with diskpart, but by the drive letter, not the disk number.

Question
-
Im trying to make a simple batch file that will automatically use diskpart to format the drive and make it bootable. But since the only information that is given at the start of the file is the drive letter, how can i get the drive number from the drive letter?
- Moved by Bill_Stewart Friday, March 15, 2019 12:27 AM This is not "scripts on demand"
Sunday, November 25, 2018 11:56 PM
All replies
-
Also if not possible, is there any command line utility that can burn an ISO to a flash drive with the drive letter?Sunday, November 25, 2018 11:59 PM
-
This is a scripting forum and is not for questions about system utilities. Please post in a more appropriate forum.
If you use your search provider you will find hundreds of answers to your questions.
\_(ツ)_/
Monday, November 26, 2018 12:28 AM -
Here is a example: https://fossbytes.com/create-bootable-usb-without-software-windows-10-using-command-prompt/
\_(ツ)_/
Monday, November 26, 2018 12:30 AM -
Here is also another one easily found by searching:
\_(ツ)_/
Monday, November 26, 2018 12:40 AM -
To get a disk drive number from a drive letter you'll need to work WMI associators. Assume drive is C: for the examples below.
In PowerShell it's simple:
(Get-WmiObject -Query "ASSOCIATORS OF {Win32_LogicalDisk.DeviceID='C:'} WHERE resultClass = Win32_DiskPartition").DiskIndex
In batch scripting it's complicated because the results are in text and you'll need to get creative to make use of that text. You can start with:
wmic LOGICALDISK WHERE DeviceID="c:" ASSOC /RESULTCLASS:Win32_DiskPartition
Monday, November 26, 2018 8:59 AM