找回密码
 加入
搜索
查看: 8063|回复: 1

[系统综合] WMI如何输出指定U盘盘符?

[复制链接]
发表于 2014-8-13 19:05:25 | 显示全部楼层 |阅读模式
; 生成于 AutoIt Scriptomatic

__wmi_Win32_DiskDrive()
Func __wmi_Win32_DiskDrive()
        Local $wbemFlagReturnImmediately = 0x10
        Local $wbemFlagForwardOnly = 0x20
        Local $colItems = ""
        Local $strComputer = "localhost"

        Local $Output=""
        $Output &= "Computer: " & $strComputer  & @CRLF
        $Output &= "==========================================" & @CRLF
        Local $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 &= "Availability: " & $objItem.Availability & @CRLF
              $Output &= "BytesPerSector: " & $objItem.BytesPerSector & @CRLF
                     Local $strCapabilities = $objItem.Capabilities(0)
              $Output &= "Capabilities: " & $strCapabilities & @CRLF
                     Local $strCapabilityDescriptions = $objItem.CapabilityDescriptions(0)
              $Output &= "CapabilityDescriptions: " & $strCapabilityDescriptions & @CRLF
              $Output &= "Caption: " & $objItem.Caption & @CRLF
              $Output &= "CompressionMethod: " & $objItem.CompressionMethod & @CRLF
              $Output &= "ConfigManagerErrorCode: " & $objItem.ConfigManagerErrorCode & @CRLF
              $Output &= "ConfigManagerUserConfig: " & $objItem.ConfigManagerUserConfig & @CRLF
              $Output &= "CreationClassName: " & $objItem.CreationClassName & @CRLF
              $Output &= "DefaultBlockSize: " & $objItem.DefaultBlockSize & @CRLF
              $Output &= "Description: " & $objItem.Description & @CRLF
              $Output &= "DeviceID: " & $objItem.DeviceID & @CRLF
              $Output &= "ErrorCleared: " & $objItem.ErrorCleared & @CRLF
              $Output &= "ErrorDescription: " & $objItem.ErrorDescription & @CRLF
              $Output &= "ErrorMethodology: " & $objItem.ErrorMethodology & @CRLF
              $Output &= "FirmwareRevision: " & $objItem.FirmwareRevision & @CRLF
              $Output &= "Index: " & $objItem.Index & @CRLF
              $Output &= "InstallDate: " & WMIDateStringToDate($objItem.InstallDate) & @CRLF
              $Output &= "InterfaceType: " & $objItem.InterfaceType & @CRLF
              $Output &= "LastErrorCode: " & $objItem.LastErrorCode & @CRLF
              $Output &= "Manufacturer: " & $objItem.Manufacturer & @CRLF
              $Output &= "MaxBlockSize: " & $objItem.MaxBlockSize & @CRLF
              $Output &= "MaxMediaSize: " & $objItem.MaxMediaSize & @CRLF
              $Output &= "MediaLoaded: " & $objItem.MediaLoaded & @CRLF
              $Output &= "MediaType: " & $objItem.MediaType & @CRLF
              $Output &= "MinBlockSize: " & $objItem.MinBlockSize & @CRLF
              $Output &= "Model: " & $objItem.Model & @CRLF
              $Output &= "Name: " & $objItem.Name & @CRLF
              $Output &= "NeedsCleaning: " & $objItem.NeedsCleaning & @CRLF
              $Output &= "NumberOfMediaSupported: " & $objItem.NumberOfMediaSupported & @CRLF
              $Output &= "Partitions: " & $objItem.Partitions & @CRLF
              $Output &= "PNPDeviceID: " & $objItem.PNPDeviceID & @CRLF
                     Local $strPowerManagementCapabilities = $objItem.PowerManagementCapabilities(0)
              $Output &= "PowerManagementCapabilities: " & $strPowerManagementCapabilities & @CRLF
              $Output &= "PowerManagementSupported: " & $objItem.PowerManagementSupported & @CRLF
              $Output &= "SCSIBus: " & $objItem.SCSIBus & @CRLF
              $Output &= "SCSILogicalUnit: " & $objItem.SCSILogicalUnit & @CRLF
              $Output &= "SCSIPort: " & $objItem.SCSIPort & @CRLF
              $Output &= "SCSITargetId: " & $objItem.SCSITargetId & @CRLF
              $Output &= "SectorsPerTrack: " & $objItem.SectorsPerTrack & @CRLF
              $Output &= "SerialNumber: " & $objItem.SerialNumber & @CRLF
              $Output &= "Signature: " & $objItem.Signature & @CRLF
              $Output &= "Size: " & $objItem.Size & @CRLF
              $Output &= "Status: " & $objItem.Status & @CRLF
              $Output &= "StatusInfo: " & $objItem.StatusInfo & @CRLF
              $Output &= "SystemCreationClassName: " & $objItem.SystemCreationClassName & @CRLF
              $Output &= "SystemName: " & $objItem.SystemName & @CRLF
              $Output &= "TotalCylinders: " & $objItem.TotalCylinders & @CRLF
              $Output &= "TotalHeads: " & $objItem.TotalHeads & @CRLF
              $Output &= "TotalSectors: " & $objItem.TotalSectors & @CRLF
              $Output &= "TotalTracks: " & $objItem.TotalTracks & @CRLF
              $Output &= "TracksPerCylinder: " & $objItem.TracksPerCylinder & @CRLF
              if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop
              $Output=""
           Next
        Else
           Msgbox(0,"WMI 输出","没有在类 " & "Win32_DiskDrive" & "中找到WMI对象" )
        Endif
EndFunc


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
 楼主| 发表于 2014-8-13 19:08:59 | 显示全部楼层
$objItem.DeviceID
显示的是驱动ID,没显示分区

请问该如何得到盘符?
通过@ScriptDir这种类型获取的不行,因为这样子并不能知道
当前程序所在的U盘,相关信息对应哪个U盘
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-11-23 01:29 , Processed in 1.606295 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表