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
Powershell?:
Get-PhysicalDisk | Select FriendlyName, MediaType
Powershell is just using WMI so you could also get the information using 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
Thank you, TD!
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)