木头人 发表于 2015-4-28 09:51:51

请问AU3能否查询磁盘是否GPT分区吗?

请问AU3能否查询磁盘是否GPT分区吗?谢谢了,能否给出具体的例子

虫子樱桃 发表于 2015-4-28 12:04:05

回复 1# 木头人
参考; 生成于虫子樱桃自用汉化版 AutoIt Scriptomatic

__wmi_Win32_DiskPartition()
Func __wmi_Win32_DiskPartition()
        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_DiskPartition", "WQL", _
                                          $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

        If IsObj($colItems) then
           For $objItem In $colItems
              $Output &= "Access: " & $objItem.Access & @CRLF
              $Output &= "Availability: " & $objItem.Availability & @CRLF
              $Output &= "BlockSize: " & $objItem.BlockSize & @CRLF
              $Output &= "Bootable: " & $objItem.Bootable & @CRLF
              $Output &= "BootPartition: " & $objItem.BootPartition & @CRLF
              $Output &= "Caption: " & $objItem.Caption & @CRLF
              $Output &= "ConfigManagerErrorCode: " & $objItem.ConfigManagerErrorCode & @CRLF
              $Output &= "ConfigManagerUserConfig: " & $objItem.ConfigManagerUserConfig & @CRLF
              $Output &= "CreationClassName: " & $objItem.CreationClassName & @CRLF
              $Output &= "Description: " & $objItem.Description & @CRLF
              $Output &= "DeviceID: " & $objItem.DeviceID & @CRLF
              $Output &= "DiskIndex: " & $objItem.DiskIndex & @CRLF
              $Output &= "ErrorCleared: " & $objItem.ErrorCleared & @CRLF
              $Output &= "ErrorDescription: " & $objItem.ErrorDescription & @CRLF
              $Output &= "ErrorMethodology: " & $objItem.ErrorMethodology & @CRLF
              $Output &= "HiddenSectors: " & $objItem.HiddenSectors & @CRLF
              $Output &= "Index: " & $objItem.Index & @CRLF
              $Output &= "InstallDate: " & WMIDateStringToDate($objItem.InstallDate) & @CRLF
              $Output &= "LastErrorCode: " & $objItem.LastErrorCode & @CRLF
              $Output &= "Name: " & $objItem.Name & @CRLF
              $Output &= "NumberOfBlocks: " & $objItem.NumberOfBlocks & @CRLF
              $Output &= "PNPDeviceID: " & $objItem.PNPDeviceID & @CRLF
                     Local $strPowerManagementCapabilities = $objItem.PowerManagementCapabilities(0)
              $Output &= "PowerManagementCapabilities: " & $strPowerManagementCapabilities & @CRLF
              $Output &= "PowerManagementSupported: " & $objItem.PowerManagementSupported & @CRLF
              $Output &= "PrimaryPartition: " & $objItem.PrimaryPartition & @CRLF
              $Output &= "Purpose: " & $objItem.Purpose & @CRLF
              $Output &= "RewritePartition: " & $objItem.RewritePartition & @CRLF
              $Output &= "Size: " & $objItem.Size & @CRLF
              $Output &= "StartingOffset: " & $objItem.StartingOffset & @CRLF
              $Output &= "Status: " & $objItem.Status & @CRLF
              $Output &= "StatusInfo: " & $objItem.StatusInfo & @CRLF
              $Output &= "SystemCreationClassName: " & $objItem.SystemCreationClassName & @CRLF
              $Output &= "SystemName: " & $objItem.SystemName & @CRLF
              $Output &= "Type: " & $objItem.Type & @CRLF
              if Msgbox(1,"WMI输出",$Output) = 2 then ExitLoop
              $Output=""
           Next
        Else
           Msgbox(0,"WMI 输出","没有在类 " & "Win32_DiskPartition" & "中找到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

bemylife 发表于 2015-4-29 13:59:57

楼上正解~~~~

bemylife 发表于 2015-4-29 14:00:07

楼上正解~~~~

cutyourchicken 发表于 2015-4-29 14:59:24

2楼正解~~~~

ap112 发表于 2015-4-30 09:14:41

2楼正解   好东西   收藏

木头人 发表于 2015-4-30 09:17:23

回复木头人
参考
虫子樱桃 发表于 2015-4-28 12:04 http://autoitx.com/images/common/back.gif


    非常感谢。

木头人 发表于 2015-4-30 09:27:16

回复木头人
参考
虫子樱桃 发表于 2015-4-28 12:04 http://autoitx.com/images/common/back.gif


    我运行不了脚本?请问是什么问题

虫子樱桃 发表于 2015-4-30 20:27:07

回复 8# 木头人


    Win7 Pro Sp1AutoIt:10.3.12测试通过

DenQ 发表于 2015-5-1 15:03:25

二楼正解..

nqawen 发表于 2015-5-4 09:43:41

谢谢,,正需要啊,,,,找了很久

yelangpp 发表于 2020-5-31 10:26:34

win10 1909运行错误:
==> Variable must be of type "Object".:
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_DiskPartition", "WQL",$wbemFlagReturnImmediately + $wbemFlagForwardOnly)
$colItems = $objWMIService^ ERROR
页: [1]
查看完整版本: 请问AU3能否查询磁盘是否GPT分区吗?