Jump to content

Should the ability to check if a drive is an SSD even work in Windows XP (using 3.3.14.0)?


Recommended Posts

Should the ability to check if a drive is an SSD even work in Windows XP?

(And yes, I know it's a can of worms to look into this on XP, trust me I am only doing what I am asked to do by someone else).

E.g., If I do the following:

#cs ----------------------------------------------------------------------------
    AutoIt Version: 3.3.14.0
    Script Function: Checks if a drive letter is an SSD drive
#ce ----------------------------------------------------------------------------
#RequireAdmin
#include <AutoItConstants.au3>

        $s_chkDrv = "E:"
        $s_isDrive = DriveGetType($s_chkDrv, $DT_DRIVETYPE)
        $s_isSSD = DriveGetType($s_chkDrv, $DT_SSDSTATUS)
        $s_whatBus = DriveGetType($s_chkDrv, $DT_BUSTYPE)

ConsoleWrite("$s_isDrive=" & $s_isDrive & @CRLF & "$s_isSSD=" & $s_isSSD & @CRLF & "$s_whatBus=" & $s_whatBus & @CRLF)

 

My results are as follows (and I know for certain the drive is an SSD):
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
$s_isDrive=Fixed
$s_isSSD=
$s_whatBus=SCSI
+>12:44:17 AutoIt3.exe ended.rc:0
+>12:44:17 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 0.4762

Always carry a towel.

Link to comment
Share on other sites

  • Moderators

Actually, where AutoIt is concerned anyway, for the new version just released the minimum supported is XP SP3 or Server 2003 SP2. The OS itself is not supported, of course.

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Nice, XP is still a good pet
I personally use this approach which usually works

Local $Output=""
$objWMIService = ObjGet("winmgmts:\\.\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_PerfRawData_PerfDisk_PhysicalDisk", "WQL", 0x10 + 0x20)
If IsObj($colItems) then
   For $objItem In $colItems
      $name = $objItem.Name
      If StringRight($name, 1) <> ":" Then ContinueLoop
      $s = ((($objItem.DiskReadBytesPersec/1024)/1024)/1024)/8
      $type = ($s > 6) ? "SSD" : "No SSD"
      $Output &= $name & " = " & $type & " (" & $s & ")" & @CRLF
   Next
Endif
Msgbox(0,"", $Output)

 

Link to comment
Share on other sites

  • Administrators

Should the ability to check if a drive is an SSD even work in Windows XP?

(And yes, I know it's a can of worms to look into this on XP, trust me I am only doing what I am asked to do by someone else).

The function uses the two methods described here to detect SSD. https://www.autoitconsulting.com/site/scripting/detect-an-ssd-disk-using-a-script/ 

But the Seek Penalty test only works on Win7 and later, so on XP you're only using the rotation rate test. Basically it's not as reliable on XP.

Link to comment
Share on other sites

Thanks, everyone. I got tapped to work on XP because I'm old. :-P
In order to assure failsafe operations (and put some responsibility on the requestor), I will instead:

  1. Make a textfile with string(s) from the expected SSD model caption.
  2. Read the textfile.
  3. Query the drive caption with WMI.
  4. Compare to the string(s) from the textfile.
  5. Act accordingly (use gdisk circa 2009 to create an aligned partition if it's a matching hard disk model number).

Always carry a towel.

Link to comment
Share on other sites

Nice, XP is still a good pet
I personally use this approach which usually works

Local $Output=""
$objWMIService = ObjGet("winmgmts:\\.\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_PerfRawData_PerfDisk_PhysicalDisk", "WQL", 0x10 + 0x20)
If IsObj($colItems) then
   For $objItem In $colItems
      $name = $objItem.Name
      If StringRight($name, 1) <> ":" Then ContinueLoop
      $s = ((($objItem.DiskReadBytesPersec/1024)/1024)/1024)/8
      $type = ($s > 6) ? "SSD" : "No SSD"
      $Output &= $name & " = " & $type & " (" & $s & ")" & @CRLF
   Next
Endif
Msgbox(0,"", $Output)

 

I get a syntax error on this one (using 3.3.8.1, which is my production code):

X:\!Dev\PixelRestore\test_drive.au3(9,24) : ERROR: syntax error (illegal character)
                    $type = ($s > 6) ?
~~~~~~~~~~~~~~~~~~~~~~~^

Always carry a towel.

Link to comment
Share on other sites

Interesting result - in the screenshot attached, disks 0, 1, and 2 are definitely SSDs (and X: is an USB flash device). Running on Windows 7 under 3.3.8.1., but I get similar incorrect results for the XP system.

Local $Output = ""
$objWMIService = ObjGet("winmgmts:\\.\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_PerfRawData_PerfDisk_PhysicalDisk", "WQL", 0x10 + 0x20)
If IsObj($colItems) Then
    For $objItem In $colItems
        $name = $objItem.name
        If StringRight($name, 1) <> ":" Then ContinueLoop
        $s = ((($objItem.DiskReadBytesPersec / 1024) / 1024) / 1024) / 8
        If $s > 6 Then
            $type = "SSD"
        Else
            $type = "No SSD"
        EndIf
        $Output &= $name & " = " & $type & " (" & $s & ")" & @CRLF
    Next
EndIf
Msgbox(0,"", $Output)

 

result.png

Always carry a towel.

Link to comment
Share on other sites

On my computer I get this.

0 C: = SSD (39.0915508270264)

1 F: = No SSD (0.104038298130035)

2 E: = No SSD (0.00145798921585083)

 0 is an SSD, running 3.3.14.0 on Windows 7 x64.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

With the new method in 3.3.14.0, the results are as expected (see small attached screenshot) on the same Windows 7 system (HP EliteBook 8570w)

However, on another Windows 7 system (HP Z840), the results are *NOT* ok with my sample code below (new method) and I know this other system has Micron SSDs in it! Now, I know that on my home system (HP Z400 with a generic 6GB SATA controlller) the new method works.

So it seems that in Windows 7 at least there can be some influence that causes this new method to produce incorrect results, but I don't know what.

Is there any information I can provide that will help find the root cause, or can someone tell me where to dig? I'm very curious about this.
<edit: all Windows 7 versions are 64-bit environments>

Not_detecting_Micron_SSDs.thumb.PNG.614f

#cs ----------------------------------------------------------------------------
    AutoIt Version: 3.3.14.0
#ce ----------------------------------------------------------------------------
#include <AutoItConstants.au3>

Local $Output = ""
$a_allDrv = DriveGetDrive("Fixed")
For $i = 1 To $a_allDrv[0]
    $s_isSSD = DriveGetType($a_allDrv[$i], $DT_SSDSTATUS)
    If $s_isSSD <> "" Then
        $s_foundSSD = "SSD"
    Else
        $s_foundSSD = "No SSD"
    EndIf
    $Output &= $a_allDrv[$i] & " = " & $s_foundSSD & @CRLF
Next
MsgBox(0, "", $Output)

 

new_method_result.png

Edited by ModemJunki
add info about Windows being x64

Always carry a towel.

Link to comment
Share on other sites

There is no safe method to detect SSD type of drive, nor there will be until manufacturers would be forced to "mark" them as such by some future standard. That will never happen though. Extending built-in function in this manner was mistake.

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

if someone can make some function to read S.M.A.R.T. and other info from drives - problem would be as good as solved, i think.

 

Look at the link in Jons post (#5), there is comment there about a tool that works with SMART. But this is not the answer - no standard exists to report the drive is SSD, mechanical, or hybrid.

I'm out of luck. I will stick with a textfile and some specific models defined inside. My requestor will have real work to do keeping the file up to date in his distribution - I know thats crazy talk. :-)

Always carry a towel.

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
 Share

×
×
  • Create New...