Determine if a file is on an SSD drive

I was trying to find out if a file was located on an SSD drive.

I can do the following;
Code:
e:\utils>pshell /s "Get-PhysicalDisk | Format-Table -AutoSize"

Number FriendlyName           SerialNumber    MediaType CanPool OperationalStatus HealthStatus Usage  Size
------ ------------           ------------    --------- ------- ----------------- ------------ -----  ----
1      WDC WD2000FYYZ-01UL1B0 WD-WCC1P0387049 HDD       False   OK                Healthy      Auto-Select   1.82 TB
2      WD My Book 25EE        WCC7K4XR8V9A    HDD       False   OK                Healthy      Auto-Select   2.73 TB
0      CT500MX500SSD1         1826E145FFE2    SSD       False   OK                Healthy      Auto-Select 465.76 GB
...which shows that drive number 0 is an SSD drive.

There is the @DRIVETYPE function, which perhaps could be modified to also indicate if the MediaType is SSD or HDD.

I found an article by Raymond Chen detailing how this can be accomplished using C++, which is beyond my skill set.

If this is not deemed as an addition to TCC, maybe it could be implemented in a plugin.

Joe
 
May 20, 2008
10,937
84
Syracuse, NY, USA
Below, MediaType 3 is HDD and 4 is SSD.

Code:
v:\> wmiquery /a root\Microsoft\Windows\Storage "select DeviceId,MediaType from MSFT_PhysicalDisk"
DeviceId = 1
MediaType = 4

DeviceId = 0
MediaType = 4

Test any one with @WMI.

Code:
v:\> echo %@wmi[root\Microsoft\Windows\Storage,"select MediaType from MSFT_PhysicalDisk where DeviceId=0"]
4

No doubt, that Powershell is doing that because it's column headers all come from that WMI class. You can see the "raw" data like this.

Code:
v:\> wmiquery /a root\Microsoft\Windows\Storage "select * from MSFT_PhysicalDisk"
AllocatedSize = 512110190592
BusType = 8
CannotPoolReason = {7}
CanPool = False
DeviceId = 1
FirmwareVersion = M0DL023
FriendlyName = Micron 1100 SATA 512GB
HealthStatus = 0
IsPartial = True
LogicalSectorSize = 512
MediaType = 4
Model = Micron 1100 SATA 512GB
ObjectId = {1}\\JJ\root/Microsoft/Windows/Storage/Providers_v2\SPACES_PhysicalDisk.ObjectId="{25c94ae8-92f0-11e9-a3b9-806e6f6e6963}:PD:{6c3af559-aba5-5fe3-a557-5e1d7d777565}"
OperationalStatus = {2}
PhysicalLocation = Integrated : Adapter 0 : Port 0 : Target 2 : LUN 0
PhysicalSectorSize = 4096
SerialNumber = 190221FDDCAD
Size = 512110190592
SpindleSpeed = 0
SupportedUsages = {1,2,3,4,5}
UniqueId = 500A075121FDDCAD
UniqueIdFormat = 3
Usage = 1
VirtualDiskFootprint = 0

AllocatedSize = 512095510528
BusType = 8
CannotPoolReason = {7}
CanPool = False
DeviceId = 0
FirmwareVersion = M0DL023
FriendlyName = Micron 1100 SATA 512GB
HealthStatus = 0
IsPartial = True
LogicalSectorSize = 512
MediaType = 4
Model = Micron 1100 SATA 512GB
ObjectId = {1}\\JJ\root/Microsoft/Windows/Storage/Providers_v2\SPACES_PhysicalDisk.ObjectId="{25c94ae8-92f0-11e9-a3b9-806e6f6e6963}:PD:{7861b992-6f46-58d5-b2f3-69e4a60e3443}"
OperationalStatus = {2}
PhysicalLocation = Integrated : Adapter 0 : Port 0 : Target 0 : LUN 0
PhysicalSectorSize = 4096
SerialNumber = 190221FDE701
Size = 512110190592
SpindleSpeed = 0
SupportedUsages = {1,2,3,4,5}
UniqueId = 500A075121FDE701
UniqueIdFormat = 3
Usage = 1
VirtualDiskFootprint = 0
 
May 20, 2008
10,937
84
Syracuse, NY, USA
I don't know if MSFT_Partition::DiskNumber and MSFT_PhysicalDisk::DeviceId match. They seem to. You can do this. BTM is attached (the forum wouldn't let mr paste it here). E: is a plugin Western Digital; Powershell also gives "Unspecified".

Code:
v:\> dtype.btm
Usage: DTYPE.BTM drive_letter[...]

v:\> dtype.btm c:\windows
SSD

v:\> dtype.btm d:\windows
SSD

v:\> dtype.btm e:\windows
UNSPECIFIED

v:\> dtype.btm f:\windows
No such disk
 
May 20, 2008
10,937
84
Syracuse, NY, USA
It didn't like DTYPE.TXT either!

Code:
v:\> type dtype.btm
setlocal

if %# == 0 (echo Usage: DTYPE.BTM drive_letter[...] & quit)

:: DriveLetter is the ASCII code of an uppercase letter; e.g., the c drive is 67

set letter=%@ascii[%@upper[%@instr[0,1,%1]]]

set DiskNumber=%@wmi[root\Microsoft\Windows\Storage,"select DiskNumber from MSFT_Partition where DriveLetter=%letter"]

if "%DiskNumber" == "" ( echoerr No such disk & quit )

set MediaType=%@wmi[root\Microsoft\Windows\Storage,"select MediaType from MSFT_PhysicalDisk where DeviceId=%DiskNumber"]

if "MediaType" == "" (echoerr Unknown error & quit)

switch %MediaType
    case 0
        echo UNSPECIFIED
    case 3
        echo HHD
    case 4
        echo SSD
    case 5
        echo SCM
    default
        echo UNKNOWN
endswitch