How to tell which disk Windows Used to Boot
Asked Answered
K

10

15

I'm need to find a method to programmatically determine which disk drive Windows is using to boot. In other words, I need a way from Windows to determine which drive the BIOS is using to boot the whole system.

Does Windows expose an interface to discover this? With how big the Windows API is, I'm hoping there is something buried in there that might do the trick.

Terry

p.s. Just reading the first sectors of the hard disk isn't reveling anything. On my dev box I have two hard disks, and when I look at the contents of the first couple of sectors on either of the hard disks I have a standard boiler plate MBR.

Edit to clarify a few things. The way I want to identify the device is with a string which will identify a physical disk drive (as opposed to a logical disk drive). Physical disk drives are of the form "\\.\PHYSICALDRIVEx" where x is a number. On the other hand, a logical drive is identified by a string of the form, "\\.\x" where x is a drive letter.

Edit to discuss a few of the ideas that were thrown out. Knowing which logical volume Windows used to boot doesn't help me here. Here is the reason. Assume that C: is using a mirrored RAID setup. Now, that means we have at least two physical drives. Now, I get the mapping from Logical Drive to Physical Drive and I discover that there are two physical drives used by that volume. Which one did Windows use to boot? Of course, this is assuming that the physical drive Windows used to boot is the same physical drive that contains the MBR.

Keen answered 2/9, 2008 at 19:14 Comment(1)
In the Command Line i.e. Run, cmd enter, type systeminfo return. Give it a minute to compile the list and the answer ither with a lot more detail.Kibitz
K
15
  1. Go into Control Panel
  2. System and Security
  3. Administrative Tools
  4. Launch the System Configuration tool

If you have multiple copies of Windows installed, the one you are booted with will be named such as:

Windows 7 (F:\Windows)
Windows 7 (C:\Windows) : Current OS, Default OS
Kalahari answered 25/8, 2013 at 1:31 Comment(1)
If you do NOT list your control panel icons by category, skip step #2 and go straight to Administrative Tools. There is no System and Security option and the 'System' option is not what you want.Homologize
J
5

Unless C: is not the drive that windows booted from.
Parse the %SystemRoot% variable, it contains the location of the windows folder (i.e. c:\windows).

Joyann answered 2/9, 2008 at 19:18 Comment(0)
O
5

You can use WMI to figure this out. The Win32_BootConfiguration class will tell you both the logical drive and the physical device from which Windows boots. Specifically, the Caption property will tell you which device you're booting from.

For example, in powershell, just type gwmi Win32_BootConfiguration to get your answer.

Obligato answered 2/9, 2008 at 21:10 Comment(0)
W
5

You type diskpart, list disk and check disks for boot.
Ex:

dispart 
list disk 
select disk 0 
detail disk

The disk with Boot volume is disk with windows installed:

enter image description here

Wolenik answered 16/10, 2020 at 21:14 Comment(0)
F
3

That depends on your definition of which disk drive Windows used to boot. I can think of 3 different answers on a standard BIOS system (who knows what an EFI system does):

  1. The drive that contains the active MBR
  2. The active partition, with NTLDR (the system partition)
  3. The partition with Windows on it (the boot partition)

2 and 3 should be easy to find - I'm not so sure about 1. Though you can raw disk read to find an MBR, that doesn't mean it's the BIOS boot device this time or even next time (you could have multiple disks with MBRs).

You really can't even be sure that the PC was started from a hard drive - it's perfectly possible to boot Windows from a floppy. In that case, both 1 and 2 would technically be a floppy disk, though 3 would remain C:\Windows.

You might need to be a bit more specific in your requirements or goals.

Fichtean answered 2/9, 2008 at 21:45 Comment(0)
E
2

There is no boot.ini on a machine with just Vista installed.

How do you want to identify the drive/partition: by the windows drive letter it is mapped to (eg. c:\, d:) or by how its hardware signature (which bus, etc).

For the simple case check out GetSystemDirectory

Edify answered 2/9, 2008 at 19:20 Comment(1)
The simple case: char path[MAX_PATH]; GetSystemDirectoryA(path, MAX_PATH); More here: msdn.microsoft.com/en-us/library/ms724373(VS.85).aspxYawl
C
1

Try HKEY_LOCAL_MACHINE\SYSTEM\Setup\SystemPartition

Cordova answered 2/9, 2008 at 19:25 Comment(2)
Are you sure the key indicate that value on uefi systems? On mine, it points to hardiskvolume2 which is the winre partition.Blindworm
This one gave me an incorrect answer as well. I suggest not using this.Gizmo
M
0

You can try use simple command line. bcdedit is what you need, just run cmd as administrator and type bcdedit or bcdedit \v, this doesn't work on XP, but hope it is not an issue.

Anyway for XP you can take a look into boot.ini file.

Moses answered 15/12, 2015 at 15:24 Comment(0)
M
0

On Windows 10. Open "Computer Management" Look for "Storage" in list "left top side of page" select "Disk Management" On section of page showing the list of disks and the partitions find the disk that has the partition assigned as drive C: On that disk containing C: partition Use the right mouse button to select the Square section containing The Disk Number, Type of drive and size in GB . When menu opens select the Properties. A window will open showing what drive hardware was used.

Mydriatic answered 15/6, 2021 at 7:16 Comment(0)
L
-1

a simpler way search downloads in the start menu and click on downloads in the search results to see where it will take you the drive will be highlighted in the explorer.

Laxative answered 1/2, 2021 at 5:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.