【问题标题】:browse file system of android device in MTP mode via powershell using a wmiobject使用 wmiobject 通过 powershell 以 MTP 模式浏览​​ android 设备的文件系统
【发布时间】:2015-01-22 15:27:42
【问题描述】:

我浏览过一些讨论如何使用 powershell 访问 USB 驱动器的帖子和文章,例如:

但他们都没有真正“回答”这个问题。上一篇分享的帖子还说,由于 MTP(协议)本身具有某些限制,没有人创建过 MTP 解决方案。

我走的一条路线有点碰壁;我不知道下一步该做什么(使用 wmi 对象)。我使用了下面的 vbscript 程序,并记下了我感兴趣的设备的设备 id 从here 获得:

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colDevices = objWMIService.ExecQuery _
    ("Select * From Win32_USBControllerDevice")

For Each objDevice in colDevices
    strDeviceName = objDevice.Dependent
    strQuotes = Chr(34)
    strDeviceName = Replace(strDeviceName, strQuotes, "")
    arrDeviceNames = Split(strDeviceName, "=")
    strDeviceName = arrDeviceNames(1)
    Set colUSBDevices = objWMIService.ExecQuery _
        ("Select * From Win32_PnPEntity Where DeviceID = '" & strDeviceName & "'")
    For Each objUSBDevice in colUSBDevices
        Wscript.Echo objUSBDevice.Description
    Next    
Next

我已经在下面的 powershell 命令中插入了它来获取 wmi 对象:

Get-WmiObject win32_pnpentity -filter "DeviceID='<the_device_id>'" 

现在我想我有了 WMI 对象。但是我能用它做什么呢。

从我链接到的上一篇文章来看,我有一种预感,有一种 COM 方法可以处理这个问题。我们该怎么做?

【问题讨论】:

    标签: android powershell com mtp


    【解决方案1】:

    要在 Power Shell 中查找 MTP 设备,请使用以下命令:

    Get-WmiObject -class win32_pnpentity -computername localhost | where-object {$_.HardwareID -like "*MTP*"} | format-list
    

    三星 Galaxy S5 的示例输出

    __GENUS : 2 __CLASS : Win32_PnPEntity __SUPERCLASS : CIM_LogicalDevice __DYNASTY : CIM_ManagedSystemElement __RELPATH : Win32_PnPEntity.DeviceID="USB\\VID_04E8&PID_6860&MS_COMP_MTP&SAMSUNG_ANDROID\\6&8F62A49&0&0000" __PROPERTY_COUNT : 24 __DERIVATION : {CIM_LogicalDevice, CIM_LogicalElement, CIM_ManagedSystemElement} __SERVER : -*- Computer Name -*- __NAMESPACE : root\cimv2 __PATH : \\-*- Computer Name -*-\root\cimv2:Win32_PnPEntity.DeviceID="USB\\VID_04E8&PID_6860&MS_COMP_MTP&SAMSUNG_ANDROID\\6&8F62A49&0&0000" Availability : Caption : -*- device display name in explorer -*- ClassGuid : {eec5ad98-8080-425f-922a-dabf3de3f69a} CompatibleID : {USB\MS_COMP_MTP, USB\Class_06&SubClass_01&Prot_01, USB\Class_06&SubClass_01, USB\Class_06...} ConfigManagerErrorCode : 0 ConfigManagerUserConfig : False CreationClassName : Win32_PnPEntity Description : SM-G900P DeviceID : USB\VID_04E8&PID_6860&MS_COMP_MTP&SAMSUNG_ANDROID\6&8F62A49&0&0000 ErrorCleared : ErrorDescription : HardwareID : {USB\VID_04E8&PID_6860&REV_0400&MS_COMP_MTP&SAMSUNG_Android, USB\VID_04E8&PID_6860&MS_COMP_MTP&SAMSUNG_Android, USB\SAMSUNG_MOBILE&MS_COMP_MTP&SAMSUNG_Android, USB\SAMSUNG_MOBILE&MI_00...} InstallDate : LastErrorCode : Manufacturer : Samsung Electronics Co., Ltd. Name : -*- device display name in explorer -*- PNPDeviceID : USB\VID_04E8&PID_6860&MS_COMP_MTP&SAMSUNG_ANDROID\6&8F62A49&0&0000 PowerManagementCapabilities : PowerManagementSupported : Service : WUDFRd Status : OK StatusInfo : SystemCreationClassName : Win32_ComputerSystem SystemName : -*- Computer Name -*-

    【讨论】:

    猜你喜欢
    • 2011-11-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-07
    相关资源
    最近更新 更多