Jump to content

Single State Disk how to findout?


lgvlgv
 Share

Recommended Posts

Yashied!

First query just returned local host?

i modifyed little but dont know if i missed something??, it dosent work with the WHERE statement but works without??

Help anyone :graduated:

-----

MsgBox(64,"test",_DriveIsSSD("\\.\PHYSICALDRIVE0"))
 
Func _DriveIsSSD($isDrive)
    Local $oService, $objItem, $Text = '',$Text1='',$Text2="",$i=0,$y=0
$strComputer = "localhost"
$oService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $oService.ExecQuery('SELECT * FROM Win32_DiskDrive WHERE DeviceID = "' & $isDrive & '"')
    For $objItem In $colItems
$Text = $objItem.PNPDeviceID & @LF
$Text1 = $objItem.Model & @LF
$text2 = $objItem.DeviceID & @LF
If StringInStr($Text, 'SSD') or StringInStr($Text1, 'SSD') Then
Return 1
Else
Return 0
EndIf
   Next
EndFunc   ;==>_DriveIsSSD
Link to comment
Share on other sites

What about this version? It's based a little bit on KaFu's version and a modified version I have in my function folder.

It was what I explained to do here >>

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
MsgBox(64, "Drive is a Solid State Drive", _DriveIsSSD("F:\")) ; Returns True Or False.
 
Func _DriveIsSSD($sDrive)
Local $aReturn[6] = [5], $aStringSplit, $oColItems, $oWMIService, $sData
 
$sDrive = StringLeft($sDrive, 1)
$oWMIService = ObjGet("winmgmts:\\localhost\")
$oColItems = $oWMIService.ExecQuery("Select * From Win32_LogicalDiskToPartition", "WQL", 0x30)
 
If IsObj($oColItems) Then
For $oObjectItem In $oColItems
$sData = StringRegExp($oObjectItem.Dependent, '(?s)(?i)Win32_LogicalDisk.DeviceID="(.*?):"', 3)
If @error Then
Return SetError(1, 0, "")
EndIf
If $sDrive = $sData[0] Then
$aReturn[1] = $sData[0]
$sData = StringRegExp($oObjectItem.Antecedent, '(?s)(?i)Win32_DiskPartition.DeviceID="(.*?)"', 3)
If @error Then
Return SetError(2, 0, "")
EndIf
$aStringSplit = StringSplit($sData[0], ",", 2)
$aReturn[2] = $aStringSplit[0]
$aReturn[3] = $aStringSplit[1]
ExitLoop
EndIf
Next
EndIf
$oColItems = $oWMIService.ExecQuery("Select * From Win32_DiskDriveToDiskPartition", "WQL", 0x30)
If IsObj($oColItems) Then
For $oObjectItem In $oColItems
$sData = StringRegExp($oObjectItem.Dependent, '(?s)(?i)Win32_DiskPartition.DeviceID="(.*?)"', 3)
If @error Then
Return SetError(3, 0, "")
EndIf
If $sData[0] = $aReturn[2] & "," & $aReturn[3] Then
$sData = StringRegExp($oObjectItem.Antecedent, '(?s)(?i)Win32_DiskDrive.DeviceID="(.*?)"', 3)
If @error Then
Return SetError(4, 0, "")
EndIf
$aReturn[4] = StringReplace($sData[0], "\\\\.\\", "\\.\")
EndIf
Next
EndIf
$oColItems = $oWMIService.ExecQuery("Select * From Win32_DiskDrive", "WQL", 0x30)
If IsObj($oColItems) Then
For $oObjectItem In $oColItems
If $oObjectItem.DeviceID = $aReturn[4] Then
$aReturn[5] = $oObjectItem.PNPDeviceID
EndIf
Next
EndIf
Return StringInStr($aReturn[5], "SSD") > 0
EndFunc ;==>_DriveIsSSD
Edited by guinness

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
MsgBox(64, "Drive is a Solid State Drive", _DriveIsSSD("C:\")) ; Returns True Or False.

Func _DriveIsSSD($sDrive)
Local $aReturn[6] = [5], $aStringSplit, $oColItems, $oWMIService, $sData

$sDrive = StringLeft($sDrive, 1)
$oWMIService = ObjGet("winmgmts:\\" & @ComputerName & "\")
$oColItems = $oWMIService.ExecQuery("Select * From Win32_LogicalDiskToPartition", "WQL", 0x30)

If IsObj($oColItems) Then
For $oObjectItem In $oColItems
$sData = StringRegExp($oObjectItem.Dependent, '(?s)(?i)Win32_LogicalDisk.DeviceID="(.*?):"', 3)
If @error Then
Return SetError(1, 0, "")
EndIf
If $sDrive = $sData[0] Then
$aReturn[1] = $sData[0]
$sData = StringRegExp($oObjectItem.Antecedent, '(?s)(?i)Win32_DiskPartition.DeviceID="(.*?)"', 3)
If @error Then
Return SetError(2, 0, "")
EndIf
$aStringSplit = StringSplit($sData[0], ",", 2)
$aReturn[2] = $aStringSplit[0]
$aReturn[3] = $aStringSplit[1]
ExitLoop
EndIf
Next
EndIf
$oColItems = $oWMIService.ExecQuery("Select * From Win32_DiskDriveToDiskPartition", "WQL", 0x30)
If IsObj($oColItems) Then
For $oObjectItem In $oColItems
$sData = StringRegExp($oObjectItem.Dependent, '(?s)(?i)Win32_DiskPartition.DeviceID="(.*?)"', 3)
If @error Then
Return SetError(3, 0, "")
EndIf
If $sData[0] = $aReturn[2] & "," & $aReturn[3] Then
$sData = StringRegExp($oObjectItem.Antecedent, '(?s)(?i)Win32_DiskDrive.DeviceID="(.*?)"', 3)
If @error Then
Return SetError(4, 0, "")
EndIf
$aReturn[4] = StringReplace($sData[0], "\\\\.\\", "\\.\")
EndIf
Next
EndIf
$oColItems = $oWMIService.ExecQuery("Select * From Win32_DiskDrive", "WQL", 0x30)
If IsObj($oColItems) Then
For $oObjectItem In $oColItems
If $oObjectItem.DeviceID = $aReturn[4] Then
$aReturn[5] = $oObjectItem.PNPDeviceID
MsgBox(64, "SSD", $oObjectItem.PNPDeviceID)
EndIf
Next
EndIf
Return StringInStr($aReturn[5], "SSD") > 0
EndFunc ;==>_DriveIsSSD

They both work on Windows 7 x64, what does the MsgBox() show in this version?

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

same "False"...

could u tell me what "Select * From Win32_LogicalDiskToPartition" should return? when i doit manually i only get "Localhost:"

i did this as a test to see what is reurned from the diffrent querys and it returned 2 empty messageboxes with "$sData4" and then the last with False

PS.

i have XP32 with 2 disks one SSD and one normal..

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
MsgBox(64, "Drive is a Solid State Drive", _DriveIsSSD("C:\")) ; Returns True Or False.
Func _DriveIsSSD($sDrive)
Local $aReturn[6] = [5], $aStringSplit, $oColItems, $oWMIService, $sData
$sDrive = StringLeft($sDrive, 1)
$oWMIService = ObjGet("winmgmts:\\" & @ComputerName & "\")
$oColItems = $oWMIService.ExecQuery("Select * From Win32_LogicalDiskToPartition", "WQL", 0x30)
If IsObj($oColItems) Then
  For $oObjectItem In $oColItems
   $sData = StringRegExp($oObjectItem.Dependent, '(?s)(?i)Win32_LogicalDisk.DeviceID="(.*?):"', 3)
   MsgBox(64, "$sData1", $sData)
   If @error Then
    Return SetError(1, 0, "")
   EndIf
   If $sDrive = $sData[0] Then
    $aReturn[1] = $sData[0]
    $sData = StringRegExp($oObjectItem.Antecedent, '(?s)(?i)Win32_DiskPartition.DeviceID="(.*?)"', 3)
    MsgBox(64, "$sData2", $sData)
    If @error Then
     Return SetError(2, 0, "")
    EndIf
    $aStringSplit = StringSplit($sData[0], ",", 2)
    $aReturn[2] = $aStringSplit[0]
    $aReturn[3] = $aStringSplit[1]
    ExitLoop
   EndIf
  Next
EndIf
$oColItems = $oWMIService.ExecQuery("Select * From Win32_DiskDriveToDiskPartition", "WQL", 0x30)
If IsObj($oColItems) Then
  For $oObjectItem In $oColItems
   $sData = StringRegExp($oObjectItem.Dependent, '(?s)(?i)Win32_DiskPartition.DeviceID="(.*?)"', 3)
   MsgBox(64, "$sData4", $sData)
   If @error Then
    Return SetError(3, 0, "")
   EndIf
   If $sData[0] = $aReturn[2] & "," & $aReturn[3] Then
    $sData = StringRegExp($oObjectItem.Antecedent, '(?s)(?i)Win32_DiskDrive.DeviceID="(.*?)"', 3)
    MsgBox(64, "$sData5", $sData)
    If @error Then
     Return SetError(4, 0, "")
    EndIf
    $aReturn[4] = StringReplace($sData[0], "\\\\.\\", "\\.\")
   EndIf
  Next
EndIf
$oColItems = $oWMIService.ExecQuery("Select * From Win32_DiskDrive", "WQL", 0x30)
If IsObj($oColItems) Then
  For $oObjectItem In $oColItems
   If $oObjectItem.DeviceID = $aReturn[4] Then
    $aReturn[5] = $oObjectItem.PNPDeviceID
    MsgBox(64, "$aReturn[5]", $aReturn[5])
    MsgBox(64, "SSD", $oObjectItem.PNPDeviceID)
   EndIf
  Next
EndIf
Return StringInStr($aReturn[5], "SSD") > 0
EndFunc   ;==>_DriveIsSSD
Edited by lgvlgv
Link to comment
Share on other sites

The reason is because StringRegExp returns an Array so try using $sData[0]. Also what system are you using? And what did the MsgBox say with my version? Because it should contain SSD in the string.

Edited by guinness

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

My Projects

WhyNotWin11
Cisco Finesse, Github, IRC UDF, WindowEx UDF

 

Link to comment
Share on other sites

Only these msg boxes returns anything or even pops up.

MsgBox(64, "$sData4", $sData[0]) <--- Returns "Disk #0, Partion #0"

MsgBox(64, "$sData4", $sData[0]) <--- Returns "Disk #1, Partion #0"

MsgBox(64, "Drive is a Solid State Drive", _DriveIsSSD("C:\")) <---- False

Link to comment
Share on other sites

What version of Windows are you using? And what does the Array display? This works on 7 x64 SP1 & XP SP3.

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
#include <Array.au3>
MsgBox(64, "Drive is a Solid State Drive", _DriveIsSSD("C:\")) ; Returns True Or False.

Func _DriveIsSSD($sDrive)
Local $aReturn[6] = [5], $aStringSplit, $oColItems, $oWMIService, $sData

$sDrive = StringLeft($sDrive, 1)
$oWMIService = ObjGet("winmgmts:\\" & @ComputerName & "\")
$oColItems = $oWMIService.ExecQuery("Select * From Win32_LogicalDiskToPartition", "WQL", 0x30)

If IsObj($oColItems) Then
For $oObjectItem In $oColItems
$sData = StringRegExp($oObjectItem.Dependent, '(?s)(?i)Win32_LogicalDisk.DeviceID="(.*?):"', 3)
If @error Then
Return SetError(1, 0, "")
EndIf
If $sDrive = $sData[0] Then
$aReturn[1] = $sData[0]
$sData = StringRegExp($oObjectItem.Antecedent, '(?s)(?i)Win32_DiskPartition.DeviceID="(.*?)"', 3)
If @error Then
Return SetError(2, 0, "")
EndIf
$aStringSplit = StringSplit($sData[0], ",", 2)
$aReturn[2] = $aStringSplit[0]
$aReturn[3] = $aStringSplit[1]
ExitLoop
EndIf
Next
EndIf
$oColItems = $oWMIService.ExecQuery("Select * From Win32_DiskDriveToDiskPartition", "WQL", 0x30)
If IsObj($oColItems) Then
For $oObjectItem In $oColItems
$sData = StringRegExp($oObjectItem.Dependent, '(?s)(?i)Win32_DiskPartition.DeviceID="(.*?)"', 3)
If @error Then
Return SetError(3, 0, "")
EndIf
If $sData[0] = $aReturn[2] & "," & $aReturn[3] Then
$sData = StringRegExp($oObjectItem.Antecedent, '(?s)(?i)Win32_DiskDrive.DeviceID="(.*?)"', 3)
If @error Then
Return SetError(4, 0, "")
EndIf
$aReturn[4] = StringReplace($sData[0], "\\\\.\\", "\\.\")
EndIf
Next
EndIf
$oColItems = $oWMIService.ExecQuery("Select * From Win32_DiskDrive", "WQL", 0x30)
If IsObj($oColItems) Then
For $oObjectItem In $oColItems
If $oObjectItem.DeviceID = $aReturn[4] Then
$aReturn[5] = $oObjectItem.PNPDeviceID
EndIf
Next
EndIf
_ArrayDisplay($aReturn)
Return StringInStr($aReturn[5], "SSD") > 0
EndFunc ;==>_DriveIsSSD

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Both these script in the threed works as they suppose to but dosent return anything that indicates one is an SSD..

This script work but dosent tell me witch disk, i tryed to add a WHERE statement but then it fails??

#include <Array.au3>
Global $valueSSD[2]
MsgBox(64,"test",_DriveIsSSD())
 
Func _DriveIsSSD()
    Local $oService, $objItem, $Text = '',$Text1='',$Text2="",$i=0,$y=0
$strComputer = "localhost"
$oService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $oService.ExecQuery("SELECT * FROM Win32_DiskDrive")
    For $objItem In $colItems
   $Text = $objItem.PNPDeviceID & @LF
   $Text1 = $objItem.Model & @LF
   $text2 = $objItem.DeviceID & @LF
  If StringInStr($Text, 'SSD') or StringInStr($Text1, 'SSD') Then
   Return 1
  Else
   Return 0
  EndIf
   Next
EndFunc   ;==>_DriveIsSSD

this is how i would like to have it..

include <Array.au3>
Global $valueSSD[2]
MsgBox(64,"test",_DriveIsSSD())
 
Func _DriveIsSSD()
    Local $oService, $objItem, $Text = '',$Text1='',$Text2="",$i=0,$y=0
$strComputer = "localhost"
$oService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $oService.ExecQuery("SELECT * FROM Win32_DiskDrive WHERE DeviceID = '\\.\PHYSICALDRIVE0'")
    For $objItem In $colItems
   $Text = $objItem.PNPDeviceID & @LF
   $Text1 = $objItem.Model & @LF
   $text2 = $objItem.DeviceID & @LF
  If StringInStr($Text, 'SSD') or StringInStr($Text1, 'SSD') Then
   Return 1
  Else
   Return 0
  EndIf
   Next
EndFunc   ;==>_DriveIsSSD
Edited by lgvlgv
Link to comment
Share on other sites

this returns whats in the bottom

; Generated by AutoIt Scriptomatic
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"
$Output=""
$Output = $Output & "Computer: " & $strComputer  & @CRLF
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive", "WQL", _
                                          $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
If IsObj($colItems) then
   For $objItem In $colItems
      $Output = $Output & "Availability: " & $objItem.Availability & @CRLF
      $Output = $Output & "BytesPerSector: " & $objItem.BytesPerSector & @CRLF
      $strCapabilities = $objItem.Capabilities(0)
      $Output = $Output & "Capabilities: " & $strCapabilities & @CRLF
      $strCapabilityDescriptions = $objItem.CapabilityDescriptions(0)
      $Output = $Output & "CapabilityDescriptions: " & $strCapabilityDescriptions & @CRLF
      $Output = $Output & "Caption: " & $objItem.Caption & @CRLF
      $Output = $Output & "CompressionMethod: " & $objItem.CompressionMethod & @CRLF
      $Output = $Output & "ConfigManagerErrorCode: " & $objItem.ConfigManagerErrorCode & @CRLF
      $Output = $Output & "ConfigManagerUserConfig: " & $objItem.ConfigManagerUserConfig & @CRLF
      $Output = $Output & "CreationClassName: " & $objItem.CreationClassName & @CRLF
      $Output = $Output & "DefaultBlockSize: " & $objItem.DefaultBlockSize & @CRLF
      $Output = $Output & "Description: " & $objItem.Description & @CRLF
      $Output = $Output & "DeviceID: " & $objItem.DeviceID & @CRLF
      $Output = $Output & "ErrorCleared: " & $objItem.ErrorCleared & @CRLF
      $Output = $Output & "ErrorDescription: " & $objItem.ErrorDescription & @CRLF
      $Output = $Output & "ErrorMethodology: " & $objItem.ErrorMethodology & @CRLF
      $Output = $Output & "Index: " & $objItem.Index & @CRLF
      $Output = $Output & "InstallDate: " & WMIDateStringToDate($objItem.InstallDate) & @CRLF
      $Output = $Output & "InterfaceType: " & $objItem.InterfaceType & @CRLF
      $Output = $Output & "LastErrorCode: " & $objItem.LastErrorCode & @CRLF
      $Output = $Output & "Manufacturer: " & $objItem.Manufacturer & @CRLF
      $Output = $Output & "MaxBlockSize: " & $objItem.MaxBlockSize & @CRLF
      $Output = $Output & "MaxMediaSize: " & $objItem.MaxMediaSize & @CRLF
      $Output = $Output & "MediaLoaded: " & $objItem.MediaLoaded & @CRLF
      $Output = $Output & "MediaType: " & $objItem.MediaType & @CRLF
      $Output = $Output & "MinBlockSize: " & $objItem.MinBlockSize & @CRLF
      $Output = $Output & "Model: " & $objItem.Model & @CRLF
      $Output = $Output & "Name: " & $objItem.Name & @CRLF
      $Output = $Output & "NeedsCleaning: " & $objItem.NeedsCleaning & @CRLF
      $Output = $Output & "NumberOfMediaSupported: " & $objItem.NumberOfMediaSupported & @CRLF
      $Output = $Output & "Partitions: " & $objItem.Partitions & @CRLF
      $Output = $Output & "PNPDeviceID: " & $objItem.PNPDeviceID & @CRLF
      $strPowerManagementCapabilities = $objItem.PowerManagementCapabilities(0)
      $Output = $Output & "PowerManagementCapabilities: " & $strPowerManagementCapabilities & @CRLF
      $Output = $Output & "PowerManagementSupported: " & $objItem.PowerManagementSupported & @CRLF
      $Output = $Output & "SCSIBus: " & $objItem.SCSIBus & @CRLF
      $Output = $Output & "SCSILogicalUnit: " & $objItem.SCSILogicalUnit & @CRLF
      $Output = $Output & "SCSIPort: " & $objItem.SCSIPort & @CRLF
      $Output = $Output & "SCSITargetId: " & $objItem.SCSITargetId & @CRLF
      $Output = $Output & "SectorsPerTrack: " & $objItem.SectorsPerTrack & @CRLF
      $Output = $Output & "Signature: " & $objItem.Signature & @CRLF
      $Output = $Output & "Size: " & $objItem.Size & @CRLF
      $Output = $Output & "Status: " & $objItem.Status & @CRLF
      $Output = $Output & "StatusInfo: " & $objItem.StatusInfo & @CRLF
      $Output = $Output & "SystemCreationClassName: " & $objItem.SystemCreationClassName & @CRLF
      $Output = $Output & "SystemName: " & $objItem.SystemName & @CRLF
      $Output = $Output & "TotalCylinders: " & $objItem.TotalCylinders & @CRLF
      $Output = $Output & "TotalHeads: " & $objItem.TotalHeads & @CRLF
      $Output = $Output & "TotalSectors: " & $objItem.TotalSectors & @CRLF
      $Output = $Output & "TotalTracks: " & $objItem.TotalTracks & @CRLF
      $Output = $Output & "TracksPerCylinder: " & $objItem.TracksPerCylinder & @CRLF
   Next
   ConsoleWrite($Output)
   FileWrite(@TempDir & "\Win32_DiskDrive.TXT", $Output )
   Run(@Comspec & " /c start " & @TempDir & "\Win32_DiskDrive.TXT" )
Else
   Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_DiskDrive" )
Endif
 
Func WMIDateStringToDate($dtmDate)
Return (StringMid($dtmDate, 5, 2) & "/" & _
StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _
& " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2))
EndFunc

Computer: localhost

Availability:

BytesPerSector: 512

Capabilities: 3

CapabilityDescriptions:

Caption: OCZ CORE_SSD

CompressionMethod:

ConfigManagerErrorCode: 0

ConfigManagerUserConfig: False

CreationClassName: Win32_DiskDrive

DefaultBlockSize:

Description: Diskenhet

DeviceID: \\.\PHYSICALDRIVE0

ErrorCleared:

ErrorDescription:

ErrorMethodology:

Index: 0

InstallDate: // ::

InterfaceType: IDE

LastErrorCode:

Manufacturer: (Standarddiskenheter)

MaxBlockSize:

MaxMediaSize:

MediaLoaded: True

MediaType: Fixed hard disk media

MinBlockSize:

Model: OCZ CORE_SSD

Name: \\.\PHYSICALDRIVE0

NeedsCleaning:

NumberOfMediaSupported:

Partitions: 1

PNPDeviceID: IDE\DISKOCZ_CORE_SSD____________________________02.10104\4B4D313038303034333134413042373020302020

PowerManagementCapabilities:

PowerManagementSupported:

SCSIBus: 0

SCSILogicalUnit: 0

SCSIPort: 0

SCSITargetId: 0

SectorsPerTrack: 63

Signature: 1265149345

Size: 64099607040

Status: OK

StatusInfo:

SystemCreationClassName: Win32_ComputerSystem

SystemName: SPEL

TotalCylinders: 7793

TotalHeads: 255

TotalSectors: 125194545

TotalTracks: 1987215

TracksPerCylinder: 255

Availability:

BytesPerSector: 512

Capabilities: 3

CapabilityDescriptions:

Caption: WDC WD1600JS-60MHB5

CompressionMethod:

ConfigManagerErrorCode: 0

ConfigManagerUserConfig: False

CreationClassName: Win32_DiskDrive

DefaultBlockSize:

Description: Diskenhet

DeviceID: \\.\PHYSICALDRIVE1

ErrorCleared:

ErrorDescription:

ErrorMethodology:

Index: 1

InstallDate: // ::

InterfaceType: IDE

LastErrorCode:

Manufacturer: (Standarddiskenheter)

MaxBlockSize:

MaxMediaSize:

MediaLoaded: True

MediaType: Fixed hard disk media

MinBlockSize:

Model: WDC WD1600JS-60MHB5

Name: \\.\PHYSICALDRIVE1

NeedsCleaning:

NumberOfMediaSupported:

Partitions: 1

PNPDeviceID: IDE\DISKWDC_WD1600JS-60MHB5_____________________10.02E04\5&5C6CFD6&0&0.0.0

PowerManagementCapabilities:

PowerManagementSupported:

SCSIBus: 0

SCSILogicalUnit: 0

SCSIPort: 1

SCSITargetId: 0

SectorsPerTrack: 63

Signature: -735390678

Size: 160039272960

Status: OK

StatusInfo:

SystemCreationClassName: Win32_ComputerSystem

SystemName: SPEL

TotalCylinders: 19457

TotalHeads: 255

TotalSectors: 312576705

TotalTracks: 4961535

TracksPerCylinder: 255

Edited by lgvlgv
Link to comment
Share on other sites

Weird, is winmgmts even running?

Try this to determine: (not my code I found it on the forum!)

MsgBox(64, "_IsServiceRunning", _IsServiceRunning("winmgmt") & @CRLF)
 
Func _IsServiceRunning($oServiceName)
Local $oWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & @ComputerName & "\root\cimv2")
Local $oColItems = $oWMIService.ExecQuery("Select * From Win32_Service Where Name = '" & $oServiceName & "'", "WQL", 0x30)
If IsObj($oColItems) Then
For $oObjectItem In $oColItems
If @error Then
Return SetError(1, 0, 0)
EndIf
Return $oObjectItem.State
Next
EndIf
Return SetError(1, 0, 0)
EndFunc ;==>_IsServiceRunning

Edit: Saw your last post seems it is by the output you got. What if you use "localhost" instead of @ComputerName? Maybe I'm missing something really obvious but it works for me.

Edited by guinness

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Check the Console of Scite!

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7#
#AutoIt3Wrapper_UseX64=N

#include <Array.au3>
MsgBox(64, "Drive is a Solid State Drive", _DriveIsSSD("C:\")) ; Returns True Or False.

Func _DriveIsSSD($sDrive)
Local $aReturn[6] = [5], $aStringSplit, $oColItems, $oWMIService, $sData

$sDrive = StringLeft($sDrive, 1)
$oWMIService = ObjGet("winmgmts:\\" & @ComputerName & "\")
$oColItems = $oWMIService.ExecQuery("Select * From Win32_LogicalDiskToPartition", "WQL", 0x30)

If IsObj($oColItems) Then
For $oObjectItem In $oColItems
ConsoleWrite("1) " & $oObjectItem.Dependent & @LF)
ConsoleWrite("2) " & $$oObjectItem.Antecedent & @LF)
$sData = StringRegExp($oObjectItem.Dependent, '(?s)(?i)Win32_LogicalDisk.DeviceID="(.*?):"', 3)
If @error Then
Return SetError(1, 0, "")
EndIf
If $sDrive = $sData[0] Then
$aReturn[1] = $sData[0]
$sData = StringRegExp($oObjectItem.Antecedent, '(?s)(?i)Win32_DiskPartition.DeviceID="(.*?)"', 3)
If @error Then
Return SetError(2, 0, "")
EndIf
$aStringSplit = StringSplit($sData[0], ",", 2)
$aReturn[2] = $aStringSplit[0]
$aReturn[3] = $aStringSplit[1]
ExitLoop
EndIf
Next
EndIf
$oColItems = $oWMIService.ExecQuery("Select * From Win32_DiskDriveToDiskPartition", "WQL", 0x30)
If IsObj($oColItems) Then
For $oObjectItem In $oColItems
ConsoleWrite("3) " & $$oObjectItem.Dependent & @LF)
ConsoleWrite("4) " & $$oObjectItem.Antecedent & @LF)
$sData = StringRegExp($oObjectItem.Dependent, '(?s)(?i)Win32_DiskPartition.DeviceID="(.*?)"', 3)
If @error Then
Return SetError(3, 0, "")
EndIf
If $sData[0] = $aReturn[2] & "," & $aReturn[3] Then
$sData = StringRegExp($oObjectItem.Antecedent, '(?s)(?i)Win32_DiskDrive.DeviceID="(.*?)"', 3)
If @error Then
Return SetError(4, 0, "")
EndIf
$aReturn[4] = StringReplace($sData[0], "\\\\.\\", "\\.\")
EndIf
Next
EndIf
$oColItems = $oWMIService.ExecQuery("Select * From Win32_DiskDrive", "WQL", 0x30)
If IsObj($oColItems) Then
For $oObjectItem In $oColItems
ConsoleWrite("5) " & $$oObjectItem.DeviceID & @LF)
ConsoleWrite("6) " & $$oObjectItem.PNPDeviceID & @LF)
If $oObjectItem.DeviceID = $aReturn[4] Then
$aReturn[5] = $oObjectItem.PNPDeviceID
EndIf
Next
EndIf
_ArrayDisplay($aReturn)
Return StringInStr($aReturn[5], "SSD") > 0
EndFunc ;==>_DriveIsSSD

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

>"C:\Program\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Documents and Settings\lasse\Skrivbord\Win32_DiskDrive.AU3" /autoit3dir "C:\Program\AutoIt3" /UserParams

+>21:23:26 Starting AutoIt3Wrapper v.2.0.1.24 Environment(Language:041d Keyboard:0000041D OS:WIN_XP/Service Pack 3 CPU:X64 OS:X86)

>Running AU3Check (1.54.19.0) params:-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7# from:C:\Program\AutoIt3

C:\Documents and Settings\lasse\Skrivbord\Win32_DiskDrive.AU3(17,22) : ERROR: syntax error (illegal character)

ConsoleWrite("2) " & $

~~~~~~~~~~~~~~~~~~~~~^

C:\Documents and Settings\lasse\Skrivbord\Win32_DiskDrive.AU3(38,22) : ERROR: syntax error (illegal character)

ConsoleWrite("3) " & $

~~~~~~~~~~~~~~~~~~~~~^

C:\Documents and Settings\lasse\Skrivbord\Win32_DiskDrive.AU3(39,22) : ERROR: syntax error (illegal character)

ConsoleWrite("4) " & $

~~~~~~~~~~~~~~~~~~~~~^

C:\Documents and Settings\lasse\Skrivbord\Win32_DiskDrive.AU3(56,22) : ERROR: syntax error (illegal character)

ConsoleWrite("5) " & $

~~~~~~~~~~~~~~~~~~~~~^

C:\Documents and Settings\lasse\Skrivbord\Win32_DiskDrive.AU3(57,22) : ERROR: syntax error (illegal character)

ConsoleWrite("6) " & $

~~~~~~~~~~~~~~~~~~~~~^

C:\Documents and Settings\lasse\Skrivbord\Win32_DiskDrive.AU3 - 5 error(s), 0 warning(s)

!>21:23:26 AU3Check ended.rc:2

>Exit code: 0 Time: 4.669

Link to comment
Share on other sites

Weird, is winmgmts even running?

Try this to determine: (not my code I found it on the forum!)

MsgBox(64, "_IsServiceRunning", _IsServiceRunning("winmgmt") & @CRLF)
 
Func _IsServiceRunning($oServiceName)
Local $oWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & @ComputerName & "\root\cimv2")
Local $oColItems = $oWMIService.ExecQuery("Select * From Win32_Service Where Name = '" & $oServiceName & "'", "WQL", 0x30)
If IsObj($oColItems) Then
For $oObjectItem In $oColItems
If @error Then
Return SetError(1, 0, 0)
EndIf
Return $oObjectItem.State
Next
EndIf
Return SetError(1, 0, 0)
EndFunc ;==>_IsServiceRunning

Edit: Saw your last post seems it is by the output you got. What if you use "localhost" instead of @ComputerName? Maybe I'm missing something really obvious but it works for me.

Running :graduated:

Link to comment
Share on other sites

here i found the $$ but it still returns "False"

>"C:\Program\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Documents and Settings\lasse\Skrivbord\Win32_DiskDrive.AU3" /autoit3dir "C:\Program\AutoIt3" /UserParams

+>21:32:56 Starting AutoIt3Wrapper v.2.0.1.24 Environment(Language:041d Keyboard:0000041D OS:WIN_XP/Service Pack 3 CPU:X64 OS:X86)

>Running AU3Check (1.54.19.0) params:-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7# from:C:\Program\AutoIt3

+>21:32:56 AU3Check ended.rc:0

>Running:(3.3.6.1):C:\Program\AutoIt3\autoit3.exe "C:\Documents and Settings\lasse\Skrivbord\Win32_DiskDrive.AU3"

3) \\SPEL\root\cimv2:Win32_DiskPartition.DeviceID="Disk #0, Partition #0"

4) \\SPEL\root\cimv2:Win32_DiskDrive.DeviceID="\\\\.\\PHYSICALDRIVE0"

3) \\SPEL\root\cimv2:Win32_DiskPartition.DeviceID="Disk #1, Partition #0"

4) \\SPEL\root\cimv2:Win32_DiskDrive.DeviceID="\\\\.\\PHYSICALDRIVE1"

5) \\.\PHYSICALDRIVE0

6) IDE\DISKOCZ_CORE_SSD____________________________02.10104\4B4D313038303034333134413042373020302020

5) \\.\PHYSICALDRIVE1

6) IDE\DISKWDC_WD1600JS-60MHB5_____________________10.02E04\5&5C6CFD6&0&0.0.0

+>21:33:02 AutoIT3.exe ended.rc:0

>Exit code: 0 Time: 7.213

Edited by lgvlgv
Link to comment
Share on other sites

i got this working if u enter a "0" or "1" :graduated:

Any ide how to make it better or smarter?

#include <Array.au3>
Global $valueSSD[2],$value="\\\\.\\PHYSICALDRIVE"
local $value1 = InputBox("Testing", "Enter the 1 or 2 character code.", "", " M2")
$value=$value&$value1
MsgBox(64,"",$value)
MsgBox(64,"test",_DriveIsSSD($value))
Func _DriveIsSSD($isDrive)
    Local $oService, $objItem, $Text = '',$Text1='',$Text2="",$i=0,$y=0
$strComputer = "localhost"
$oService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $oService.ExecQuery("SELECT * FROM Win32_DiskDrive WHERE DeviceID = '"&$isDrive&"'")
    For $objItem In $colItems
   $Text = $objItem.PNPDeviceID & @LF
   $Text1 = $objItem.Model & @LF
   $text2 = $objItem.DeviceID & @LF
  If StringInStr($Text, 'SSD') or StringInStr($Text1, 'SSD') Then
   Return 1
   Exit
  Else
   Return 0
  EndIf
   Next
EndFunc   ;==>_DriveIsSSD
Edited by lgvlgv
Link to comment
Share on other sites

Yeh sorry about that, you can tell I did it really quickly. Where is 1 & 2, very strange indeed. What happens if you run the example for Win32_LogicalDiskToPartition from Scriptomatic?

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

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

  • Recently Browsing   0 members

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