WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: mcjathan on November 12, 2019, 11:42:42 AM

Title: Detect if a Disk is SSD?
Post by: mcjathan 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
Title: Re: Detect if a Disk is SSD?
Post by: morenos1 on November 13, 2019, 06:39:30 AM
Powershell?:

Get-PhysicalDisk | Select FriendlyName, MediaType
Title: Re: Detect if a Disk is SSD?
Post by: td on November 13, 2019, 08:25:49 AM
Powershell is just using WMI so you could also get the information using WinBatch.

Code (winbatch) Select
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
Title: Re: Detect if a Disk is SSD?
Post by: mcjathan on November 13, 2019, 11:28:23 AM
Thank you, TD!
Title: Re: Detect if a Disk is SSD?
Post by: td 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 (https://docs.microsoft.com/en-us/previous-versions/windows/desktop/stormgmt/msft-physicaldisk)