0

I am trying to write a BAT script to produce a grub4dos menu.lst file.

A boot entry in the menu.lst file typically contains a line like:

root (hdx,y)

where x is the hard disk number(first disk hd0) and y is the partition number on the disk (first partition is 0). How can I find the disk and partition numbers of %systemdrive% ?

The script will be running under Windows Vista or 7.

Wes
  • 1

1 Answers1

1
WMIC LogicalDisk GET param1, param2 (etc.)

I'm not sure there is a partition number as such. A list of the WMI classes (e.g. LogicalDisk) that you can inspect is here: MSDN

If you're using Windows 7 the Powershell alternative is:

Get-WmiObject Win32_LogicalDisk | Where {$_.DriveType -eq "3"} | Select param1, param2

EDIT: There is a class for specific partitions: Win32_DiskPartition this does contain an Index property. The Name property will give you both the disk and partition id (but you will have to parse it).

BoyMars
  • 1,012
  • 1
  • 6
  • 15