Sign in to follow this  
Followers 0
Nunos

DriveGetDrive and DriveGetType

3 posts in this topic

I have a script that runs a defraggler function off a button push in a GUI but I realized that I need to detect all of the Fixed drives and whether or not they are Solid State Drives or old spinners before I run it. The Defraggler Func works great but I am not sure if I have the below code right for detecting ssd's and then skipping them and only running the function on the old spinning types. Not sure if this is 1) Right and 2) Where and how to make it run the other function.

#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>

Local $aArray = DriveGetDrive($DT_FIXED)
If @error Then
    ; An error occurred when retrieving the drives.
    MsgBox($MB_SYSTEMMODAL, "", "It appears an error occurred.")
Else
    For $i = 1 To $aArray[0]
        ; Show all the drives found and convert the drive letter to uppercase.
        ;MsgBox($MB_SYSTEMMODAL, "", "Drive " & $i & "/" & $aArray[0] & ":" & @CRLF & StringUpper($aArray[$i]))
        DriveGetType($i,$DT_SSDSTATUS)
        MsgBox($MB_SYSTEMMODAL, "ERROR", "Your drive is a solid state drive. You shouldn't run Defrag on it try the Windows Optimization instead." & $DT_SSDSTATUS)
    Next
EndIf

Thank you in advance for any help and direction.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Try This:

Local $aArray = DriveGetDrive("FIXED")
If @error Then
    ; An error occurred when retrieving the drives.
    MsgBox(32, "", "It appears an error occurred.")
Else
    For $i = 1 To $aArray[0]
        ; Show all the drives found and convert the drive letter to uppercase.
        ;MsgBox($MB_SYSTEMMODAL, "", "Drive " & $i & "/" & $aArray[0] & ":" & @CRLF & StringUpper($aArray[$i]))
        If DriveGetType($aArray[$i], 2) <> "" Then
            MsgBox(48, "ERROR", "Your drive (" & StringUpper($aArray[$i]) & ") is a solid state drive. You shouldn't run Defrag on it try the Windows Optimization instead.")
        Else
            MsgBox(32, "OK", "Drive (" & StringUpper($aArray[$i]) & ") not is a solid state drive")
        EndIf
    Next
EndIf

 

Edited by VIP
not

Regards,
 

Share this post


Link to post
Share on other sites

Awesome thank you VIP I will try to add it to my script and test on a few different systems. :D

 

 

Share this post


Link to post
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
Sign in to follow this  
Followers 0