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
11,400
99
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
11,400
99
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
11,400
99
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
 
Similar threads
Thread starter Title Forum Replies Date
Joe Caverly Link in Help File to Blog Articles Suggestions 0
Joe Caverly Declined Use ADS file with TOAST Suggestions 1
vefatica File name completion at the beginning of the command line Suggestions 6
Joe Caverly Done @FILESIZE and NTFS File Stream Suggestions 1
Joe Caverly Declined Debug without first saving to a file Suggestions 3
R Declined File Explorer enhancement request Suggestions 8
D Secondary shells should not search for - but reuse - the current configuration file. Suggestions 11
Joe Caverly Declined Update FFIND in Help File with example for ORing expressions to search for Suggestions 6
D Done Re-activate the [secondary] section in the ini-file Suggestions 0
x13 Done Typo in help file (including PDF) | v24.02.46 Suggestions 0
R Declined wish-list: add a command to copy a file to clipboard. Suggestions 17
M Done Parameter to ignore [Escape] for FFIND /T"XXX" in a file Suggestions 5
Joe Caverly Done File completion for LIBRARY commands Suggestions 1
vefatica Declined Enhance file name completion Suggestions 4
D Declined File Explorer Suggestions 2
R Declined Install option: Add File Explorer Run As Adminstrator option Suggestions 14
mfarah Done TCEDIT: show the full name (with drive and path) of the active file on the title bar. Suggestions 3
R User-created extended help (probably in a text file): DIRHISTORY /?x Suggestions 10
Joe Caverly Declined Help File "See Also" Suggestions 4
thorntonpg Done Goto folder in file explorer from the current directory in the tcc prompt Suggestions 7
rconn add support for batch file projects Suggestions 0
rconn Done map the registry as a file system Suggestions 0
rconn Declined Help file organization Suggestions 0
rconn Done extend tcc file format Suggestions 0
K_Meinhard File descriptions for Explorer etc. Suggestions 1
J Directory Aliases and file:// Suggestions 0
M Done Verify validity of file name and/or path... Suggestions 2
G Declined Add option to turn on file name case sensitivity Suggestions 6
Stefano Piccardi Declined enhance FOR and DO with hexadecimal @file reading Suggestions 0
Joe Caverly Declined NTFS File Streams and ZIP Suggestions 12
M Declined Function to to verify file name validity... Suggestions 4
J Declined Suggestions for file size display Suggestions 0
S Done Automatic quoting of directory and file names Suggestions 0
S Declined Enhanced file comparisons Suggestions 0
S Declined File timestamp based dates in file date selection ranges Suggestions 0
C Done "extended" icon display in file-view Suggestions 0
S Done File matching enhancements Suggestions 1
S Done File exclusion ranges, additional orderng and reporting options Suggestions 0
S Declined Enhanced @FILE for COPY, DESCRIBE, MOVE, RENAME, SYNC, TOUCH /R Suggestions 0
J Declined Test batch file for TCCLE compatability Suggestions 0
B Declined Direct/shortcut access to the File Search finctionality Suggestions 2
Charles Dye Declined Help file request Suggestions 2
K_Meinhard Declined file tags (mp3, jpg" Suggestions 19
H Done Start TCMD.EXE with an alternate INI file Suggestions 4

Similar threads