Jump to content

Need script to detect SSD


Recommended Posts

Hi Guys,

I'm developing an image and I have some SSDs in some of the PCs that need a couple of utilities but I don't want all the PCs to have them. I thought that the easiest thing to do would be to detect whether there was an SSD present.

Boy was I mistaken...

Has anyone written a script that can detect an SSD or maybe even the spin rate on a HDD as the SSD will be '0' so it would be an easy detect that way?

I cannot find anything in WMI that appears to detect the SSD, or Diskpart other than name and that will change with product rolls.

Help me OB1 you're my only hope...

Thanks,

RD

Link to comment
Share on other sites


I do not known if this script will help but give it a try. This list drive letter and drive type

FsoDrives.vbs


Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject")
Dim Obj, Drv
'-> To Run In Csript Only
If InStr(1,WScript.FullName,"cscript",1) Then
ListDrives()
'-> End Of Script
WScript.StdOut.WriteLine "Press Enter To Close Window"
Do While WScript.StdIn.AtEndOfLine
WScript.Quit()
Loop
ElseIf InStr(1,WScript.FullName,"wscript",1) Then
MsgBox _
"Wrong Scripting Engine Error. To Use This Script." & vbCrLf & _
"You Must Right Click The Script And Select The " & vbCrLf & _
"Cmd Prompt As The Engine To Run The Script.",4128,"Error Wrong Engine"
End If
'-> List Drive Letter And Drive Type
Function ListDrives()
For Each Obj In Fso.Drives
Select Case Obj.DriveType
Case 1 :Drv = "Removable"
Case 2 :Drv = "Fixed"
Case 3 :Drv = "Network"
Case 4 :Drv = "CdDvd"
Case 5 :Drv = "RAMDisk"
Case Else :Drv = "Unknown"
End Select
WScript.StdOut.WriteLine Obj.DriveLetter & " - " & Drv
Next
WScript.StdOut.WriteBlankLines 1
End Function

Wmi Script that list drive letter and drive type

WmiDrives.vbs


Dim Wmi :Set Wmi = GetObject("winmgmts:\\.\root\CIMV2")
Dim Drv, Obj
'-> To Run In Csript Only
If InStr(1,WScript.FullName,"cscript",1) Then
ListDrives()
'-> End Of Script
WScript.StdOut.WriteLine "Press Enter To Close Window"
Do While WScript.StdIn.AtEndOfLine
WScript.Quit()
Loop
ElseIf InStr(1,WScript.FullName,"wscript",1) Then
MsgBox _
"Wrong Scripting Engine Error. To Use This Script." & vbCrLf & _
"You Must Right Click The Script And Select The " & vbCrLf & _
"Cmd Prompt As The Engine To Run The Script.",4128,"Error Wrong Engine"
End If
'-> List Drive Letter And Drive Type
Function ListDrives()
For Each Obj In Wmi.ExecQuery("SELECT * FROM Win32_LogicalDisk")
Select Case Obj.DriveType
Case 0 :Drv = "Unknown"
Case 1 :Drv = "No Root Directory"
Case 2 :Drv = "Removable Disk"
Case 3 :Drv = "Local Disk"
Case 4 :Drv = "Network Drive"
Case 5 :Drv = "Optical Drive"
Case 6 :Drv = "Ram Disk"
End Select
WScript.StdOut.WriteLine Chr(160) & Obj.DeviceID & " - " & Drv
Next
WScript.StdOut.WriteBlankLines 1
End Function

Rename FsoDrives.vbs.txt to FsoDrives.vbs to make active

Rename WmiDrives.vbs.txt to WmiDrives.vbs to make active

FsoDrives.vbs.txt

WmiDrives.vbs.txt

Link to comment
Share on other sites

On way would be checking smart attributes with smartctl from smartmontools. Some smart attributes are only available for ssd like"173 (ADh) Wear Leveling Count" and smartctl already identify model family of the tested drive which might already be enough.

I just check and indeed smartctl has almost all family of ssd so checking the model family would most likely be enough:

MODEL FAMILY:       Apple SSD SM128
MODEL FAMILY: Asus-Phison SSD
MODEL FAMILY: Crucial RealSSD C300
MODEL FAMILY: SandForce Driven SSDs
MODEL FAMILY: Indilinx Barefoot based SSDs
MODEL FAMILY: Intel X25-E SSDs
MODEL FAMILY: Intel X18-M/X25-M G1 SSDs
MODEL FAMILY: Intel X18-M/X25-M/X25-V G2 SSDs
MODEL FAMILY: Intel X18-M/X25-M/X25-V G2 SSDs
MODEL FAMILY: Intel 320 Series SSDs
MODEL FAMILY: Intel 510 Series SSDs
MODEL FAMILY: Kingston branded X25-V SSDs
MODEL FAMILY: Kingston branded X25-V SSDs
MODEL FAMILY: JMicron based SSDs
MODEL FAMILY: JMicron based SSDs
MODEL FAMILY: Samsung based SSDs
MODEL FAMILY: Marvell SSD SD88SA024BA0 (SUN branded)

Edited by allen2
Link to comment
Share on other sites

  • 3 weeks later...

You might be able to parse the output of some command line tool but you're not going to detect this using a simple script (from scratch). You'd need to dig into the WDK (Windows Driver Kit) and have a pretty solid understanding of VC++ (and have Visual Studio handy), so you can use the DeviceIoControl API to send a IOCTL_ATA_PASS_THROUGH request, with the IDENTIFY DEVICE command (filling a ATA_PASS_THROUGH_EX structure), which you can use to extract word 217 (nominal media rotation rate) which should be set to 0x0001 for non-rotating media including SSDs (but may be misreported by some drives)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...