Get only information from PHYSICALDRIVE0.

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
PAB
Posts: 139
Joined: 12 Aug 2019 13:57

Get only information from PHYSICALDRIVE0.

#1 Post by PAB » 08 Nov 2019 07:32

Good morning,

I have spent hours on the following which works fine if a USB or external HDD is NOT attached . . .

Code: Select all

For /f "Tokens=2 Delims==" %%a In ('wmic DiskDrive Get Caption /Value') Do Set "PC_HDDMakeModel=%%a"
For /f "Tokens=2 Delims='='" %%a In ('wmic LogicalDisk Get Description /Value') Do Set "PC_HDDMediaType=%%a"
For /f "Tokens=2 Delims='='" %%a In ('wmic DiskDrive Get Partitions /Value') Do Set PC_HDDPartitions=%%a
For /f "Tokens=2 Delims='='" %%a In ('wmic DiskDrive Get Status /Value') Do Set PC_HDDStatus=%%a
If there IS a USB or external HDD attached, it shows the USB or external HDD data instead of the C:\ drive data.

I have tried using PHYSICALDRIVE0 and wmic Path win32_PhysicalMedia Get, etc, but to no avail.

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Get only information from PHYSICALDRIVE0.

#2 Post by aGerman » 08 Nov 2019 10:18

Hint:
run this in a cmd window ...
WMIC Path class-name GET /value
... where you have to replace class-name with the WMI class you want to check. This will output all members of the class with the related values. Use the member which is suitable for filtering the output along with a WHERE statement in the WQL query.
E.g.

Code: Select all

WMIC DiskDrive WHERE "DeviceID='\\\\.\\PHYSICALDRIVE0'" GET Caption /value
Steffen

Post Reply