meoit Posted October 6, 2016 Posted October 6, 2016 (edited) Hi all. I want to get DiskName (Friendly Name) of FIXED and Removable Disks without using DiskPart, WMI, WMIC. DiskName is not Label Name. Example, SATA SAMSUNG HD251HJ... P/S: I am using WinPE and MiniXP. Thanks for reading. Edited October 7, 2016 by meoit
AutoBert Posted October 6, 2016 Posted October 6, 2016 Try this small example: expandcollapse popup#include <Array.au3> Global $aDrives[26][10] _CreateDriveItems() Func _CreateDriveItems($bDelete = False) Local $aLdrives, $iFound, $hIcon $aLdrives = DriveGetDrive('ALL') _ArrayDelete($aLdrives, 0) ;_ArrayDisplay($aLdrives) For $i = 25 To 0 Step -1 If $bDelete And $aDrives[$i][0] <> '' Then ;_GUICtrlTreeView_Delete($idTVLocal, $aDrives[$i][0]) $aDrives[$i][0] = '' EndIf $iFound = _ArraySearch($aLdrives, Chr($i + 65) & ':') If @error Then If $aDrives[$i][0] <> '' Then ;_GUICtrlTreeView_Delete($idTVLocal, $aDrives[$i][0]) $aDrives[$i][0] = '' EndIf Else If $aDrives[$i][0] = '' Then $aDrives[$i][0] = Chr($i + 65) $aDrives[$i][1] = DriveGetType($aLdrives[$iFound] & '\') $aDrives[$i][2] = DriveGetType($aLdrives[$iFound] & '\', 2) $aDrives[$i][3] = DriveGetType($aLdrives[$iFound] & '\', 3) $aDrives[$i][4] = DriveStatus($aLdrives[$iFound] & '\') $aDrives[$i][5] = Hex(DriveGetSerial($aLdrives[$iFound] & '\')) $aDrives[$i][6] = DriveGetLabel($aLdrives[$iFound] & '\') $aDrives[$i][7] = DriveGetFileSystem($aLdrives[$iFound] & '\') $aDrives[$i][8] = DriveSpaceFree($aLdrives[$iFound] & '\') $aDrives[$i][9] = DriveSpaceTotal($aLdrives[$iFound] & '\') #cs Switch $aDrives[$i][1] Case 'Unknown' $hIcon = $UNKNOWN_ICON_INDEX Case 'RAMDisk' $hIcon = $Ram_ICON_INDEX Case 'CDRom' $hIcon = $CDRom_ICON_INDEX Case 'Fixed' $hIcon = $HDD_ICON_INDEX Case 'Removavle' $hIcon = $Removable_ICON_INDEX Case 'Network' $hIcon = $Network_ICON_INDEX EndSwitch If $bDelete Then $aDrives[$i][0] = _GUICtrlTreeView_AddChildFirst($idTVLocal, $hLocal, Chr($i + 65) & ':\', $hIcon, $hIcon) Else $aDrives[$i][0] = _GUICtrlTreeView_AddChild($idTVLocal, $hLocal, Chr($i + 65) & ':\', $hIcon, $hIcon) EndIf _GUICtrlTreeView_SetItemParam($idTVLocal, $aDrives[$i][0], $aDrives[$i][0]) _AddFolderLocal($aLdrives[$iFound] & '\', $aDrives[$i][0]) _GUICtrlTreeView_Expand($idTVLocal, $aDrives[$i][0], False) #ce EndIf EndIf Next _ArrayInsert($aDrives,0) $aDrives[0][1] = 'Drive Type' $aDrives[0][2] = 'SSD Status' $aDrives[0][3] = 'Bus Type' $aDrives[0][4] = 'Drive Status' $aDrives[0][5] = 'Windows Volume ID' $aDrives[0][6] = 'Label' $aDrives[0][7] = 'File System Type' $aDrives[0][8] = 'Free Space' $aDrives[0][9] = 'Space Total' _ArrayDisplay($aDrives) EndFunc ;==>_CreateDriveItems meoit 1
meoit Posted October 6, 2016 Author Posted October 6, 2016 Thanks AutoBert. I still can not find Disk Name.
meoit Posted October 6, 2016 Author Posted October 6, 2016 Hi all. I want to get UnAllocated Disks (include Fixed Disk and Removable Disk) without using DiskPart, WMI, WMIC. Thanks for reading.
Moderators JLogan3o13 Posted October 6, 2016 Moderators Posted October 6, 2016 (edited) And I want to be rich without having to go to work, but it is unlikely. Why are you limiting yourself from the most viable ways to accomplish what you're after? Edit: Merged threads, please stick to one in the future. Edited October 6, 2016 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!
spudw2k Posted October 6, 2016 Posted October 6, 2016 (edited) Agreed. What's wrong with using WMI? I could see partdisk being an issue if you don't have admins rights, but WMI seems viable....as long as it's enabled and running. Local $sComputer = "." Local $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $sComputer & "\root\cimv2") Local $colDiskDrives = $objWMIService.ExecQuery ("Select * from Win32_DiskDrive") For $objDiskDrive in $colDiskDrives Local $sDisk = "Caption: " & $objDiskDrive.Caption & @CRLF & _ "Device ID: " & $objDiskDrive.DeviceID & @CRLF msgbox(0,"",$sDisk) Next Another method which uses the DeviceAPI UDF. #include <Array.au3> #include <DeviceAPI.au3> ;Populate Installed System Devices Array Dim $arrHW[1][2] = [["Device Class", "FriendlyName"]] $devIDX = 1 _DeviceAPI_Open() _DeviceAPI_GetAllDevices() ;Build list of ALL device classes While _DeviceAPI_EnumDevices() Local $sDeviceClass = _DeviceAPI_GetClassName(_DeviceAPI_GetDeviceRegistryProperty($SPDRP_CLASSGUID)) If $sDeviceClass = "DiskDrive" Then ReDim $arrHW[$devIDX + 1][2] $arrHW[$devIDX][0] = $sDeviceClass $arrHW[$devIDX][1] = _DeviceAPI_GetDeviceRegistryProperty($SPDRP_FRIENDLYNAME) $devIDX += 1 EndIf WEnd _DeviceAPI_DestroyDeviceInfoList() ;Cleanup for good measure _DeviceAPI_Close() _ArrayDisplay($arrHW) Edited October 6, 2016 by spudw2k meoit 1 Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
meoit Posted October 7, 2016 Author Posted October 7, 2016 (edited) Thanks to SpudW2k. Result: blank Test with Windows 7 SP1 x64. Edited October 7, 2016 by meoit
AutoBert Posted October 7, 2016 Posted October 7, 2016 Try this one: expandcollapse popup; Generated by AutoIt Scriptomatic $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $sComputer = "localhost" $Output="" $Output = $Output & "Computer: " & $sComputer & @CRLF $Output = $Output & "==========================================" & @CRLF $oWMIService = ObjGet("winmgmts:\\" & $sComputer & "\") $colItems = $oWMIService.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 & "FirmwareRevision: " & $objItem.FirmwareRevision & @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 & "SerialNumber: " & $objItem.SerialNumber & @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 If MsgBox(1,"WMI Output",$Output) = 2 Then ExitLoop $Output="" Next 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 meoit 1
meoit Posted October 7, 2016 Author Posted October 7, 2016 Thanks to AutoBert. The Above codes working. But it use WMI. $oWMIService = ObjGet("winmgmts:\\" & $sComputer & "\") Can you transfer it to not using WMI?.
AutoBert Posted October 7, 2016 Posted October 7, 2016 2 minutes ago, meoit said: Can you transfer it to not using WMI?. No, i am not able. meoit 1
Moderators JLogan3o13 Posted October 7, 2016 Moderators Posted October 7, 2016 Again, why can you not use WMI? If you explain the restrictions keeping you from using the common sense approach, perhaps people will understand better and will be able to assist with a workaround. meoit 1 "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!
meoit Posted October 7, 2016 Author Posted October 7, 2016 I am need for WinPE. Because, WinPE not include WMI.
Moderators JLogan3o13 Posted October 7, 2016 Moderators Posted October 7, 2016 (edited) Rather than trying to re-skin the cat, why not just install the WMI scripting package, as MS intended? https://msdn.microsoft.com/en-us/windows/hardware/commercialize/manufacture/desktop/winpe-add-packages--optional-components-reference BTW: Had you provided that information in the first post, you would have gotten a lot clearer answers Edited October 7, 2016 by JLogan3o13 meoit 1 "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!
meoit Posted October 7, 2016 Author Posted October 7, 2016 Thanks to MOD. I do not know to build WinPE. I only need get Disk Name (Friendly Name) in the WinPE environment.
meoit Posted October 7, 2016 Author Posted October 7, 2016 I found this code, but not working in Mini XP (WinPE v2.0 or above is working). Local $Drives = '' Local $Var = GET_DISKS_NAME() If Not @error Then For $J = 1 To $Var[0] $Drives = $Drives & ($Var[$J] & ' - ID: ' & $J - 1 & @CRLF) Next MsgBox(64, 'My DISKS', $Drives) EndIf Func GET_DISKS_NAME() Local $Disk = "HKLM\SYSTEM\CurrentControlSet\Services\Disk\Enum\" Local $Enum = "HKLM\SYSTEM\CurrentControlSet\Enum\" Local $Count = RegRead("HKLM\SYSTEM\CurrentControlSet\Services\Disk\Enum\", "Count") Dim $Return[$Count + 1] $Return[0] = $Count For $J = 1 To $Count $Return[$J] = RegRead($Enum & RegRead($Disk, $J - 1), "FriendlyName") Next Return $Return EndFunc Are you have more idea?.
jguinch Posted October 7, 2016 Posted October 7, 2016 can you try this code ? Local $aSubKeys, $i = 0, $sKeyPath = "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\IDE" While 1 $i += 1 $sSubKey = RegEnumKey($sKeyPath, $i) If @error Then ExitLoop $sSubkeyDevice = RegEnumKey($sKeyPath & "\" & $sSubKey, 1) If @error Then ContinueLoop Local $sClass = RegRead($sKeyPath & "\" & $sSubKey & "\" & $sSubkeyDevice, "Class") Local $sFriendlyName = RegRead($sKeyPath & "\" & $sSubKey & "\" & $sSubkeyDevice, "FriendlyName") ConsoleWrite($sFriendlyName & " [" & $sClass & "]" & @CRLF) WEnd meoit 1 Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
meoit Posted October 7, 2016 Author Posted October 7, 2016 (edited) Thanks to jGUInch. I tested your code in Mini XP (Hiren'sBootCD). It's not get any Disks or USB. In the main my Windows 7 x64, it's only show one Disk (which have OS.) Image test: . I guess I wrong between reading IDE/SATA Registry Key... Someone help me. Edited October 7, 2016 by meoit
jguinch Posted October 7, 2016 Posted October 7, 2016 try with USBSTOR instead of IDE in the registry path Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
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