randalldale Posted June 10, 2011 Posted June 10, 2011 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
gunsmokingman Posted June 10, 2011 Posted June 10, 2011 I do not known if this script will help but give it a try. This list drive letter and drive typeFsoDrives.vbsDim 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 FunctionWmi Script that list drive letter and drive typeWmiDrives.vbsDim 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 activeRename WmiDrives.vbs.txt to WmiDrives.vbs to make activeFsoDrives.vbs.txtWmiDrives.vbs.txt
allen2 Posted June 10, 2011 Posted June 10, 2011 (edited) 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 SM128MODEL FAMILY: Asus-Phison SSDMODEL FAMILY: Crucial RealSSD C300MODEL FAMILY: SandForce Driven SSDsMODEL FAMILY: Indilinx Barefoot based SSDsMODEL FAMILY: Intel X25-E SSDsMODEL FAMILY: Intel X18-M/X25-M G1 SSDsMODEL FAMILY: Intel X18-M/X25-M/X25-V G2 SSDsMODEL FAMILY: Intel X18-M/X25-M/X25-V G2 SSDsMODEL FAMILY: Intel 320 Series SSDsMODEL FAMILY: Intel 510 Series SSDsMODEL FAMILY: Kingston branded X25-V SSDsMODEL FAMILY: Kingston branded X25-V SSDsMODEL FAMILY: JMicron based SSDsMODEL FAMILY: JMicron based SSDsMODEL FAMILY: Samsung based SSDsMODEL FAMILY: Marvell SSD SD88SA024BA0 (SUN branded) Edited June 10, 2011 by allen2
CoffeeFiend Posted June 29, 2011 Posted June 29, 2011 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)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now