Author Topic: Detect if a Disk is SSD?  (Read 97 times)

mcjathan

  • Newbie
  • *
  • Posts: 40
Detect if a Disk is SSD?
« on: November 12, 2019, 11:42:42 am »
Greetings,

Is there any way within a Winbatch script to detect if a disk is an SSD?  I've looked at both DiskInfo and DiskVolInfo, and also searched this forum and the tech database, and I'm not seeing it.

Suggestions?

Jeff

morenos1

  • Jr. Member
  • **
  • Posts: 84
Re: Detect if a Disk is SSD?
« Reply #1 on: November 13, 2019, 06:39:30 am »
Powershell?:

Get-PhysicalDisk | Select FriendlyName, MediaType

td

  • Tech Support
  • *****
  • Posts: 3103
    • WinBatch
Re: Detect if a Disk is SSD?
« Reply #2 on: November 13, 2019, 08:25:49 am »
Powershell is just using WMI so you could also get the information using WinBatch.

Code: Winbatch
objWMIService = ObjectGet("winmgmts:{impersonationLevel=impersonate}!\\.\ROOT\Microsoft\Windows\Storage")

; MediaType is stored as an integer where 4 = SSD
strQuery = "SELECT * FROM MSFT_PhysicalDisk WHERE MediaType = 4"
colDisks = objWMIService.ExecQuery( strQuery )    
ForEach objDisk in colDisks
   Pause('Drive ':objDisk.FriendlyName, 'MediaType ':objDisk.MediaType)
Next
 

The media types are:
Value    Meaning

0          Unspecified
3              HDD
4              SSD
5             SCM
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

mcjathan

  • Newbie
  • *
  • Posts: 40
Re: Detect if a Disk is SSD?
« Reply #3 on: November 13, 2019, 11:28:23 am »
Thank you, TD!

td

  • Tech Support
  • *****
  • Posts: 3103
    • WinBatch
Re: Detect if a Disk is SSD?
« Reply #4 on: November 13, 2019, 01:09:52 pm »
Here is a link to the WMI class's complete description.  (You can ignore the dire warning histrionics at the top of the page. WMI isn't going anywhere and is more or less self-documenting.)

https://docs.microsoft.com/en-us/previous-versions/windows/desktop/stormgmt/msft-physicaldisk
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade