【发布时间】:2017-10-21 00:12:47
【问题描述】:
我正在尝试访问 MTP 设备存储以自动执行文件复制、备份等。 如果 Windows 资源管理器能够打开和浏览 Android 设备内部存储和连接的 SD 卡,我如何使用 PowerShell 访问这些存储?
I've found a lots of hints, such as "get device ID and use WMI"
Windows Explorer 使用什么方式打开和浏览特别是 Android 的存储?
Is it possible to use some System.IO Class like here?
$drives = [System.IO.DriveInfo]::GetDrives()
$r = $drives | Where-Object { $_.DriveType -eq 'Removable' -and $_.IsReady }
if ($r) {
return @($r)[-1]
}
我可以通过以下方式访问和浏览本地 MTP (android) 设备的内容:
$WIAdialog = New-Object -ComObject “WIA.CommonDialog”
$Device = $WIAdialog.ShowSelectDevice()
$Device = $WIAdialog.ShowAcquireImage()
$Device = $WIAdialog.ShowAcquisitionWizard()
$Device = $WIAdialog.ShowDeviceProperties()
$Device = $WIAdialog.ShowItemProperties()
$Device = $WIAdialog.ShowPhotoPrintingWizard()
$Device = $WIAdialog.ShowSelectItems()
$Device = $WIAdialog.ShowTransfer()
但此代码正在加载有关存储图片的信息,即使在本地计算机上也太慢了。是否可以避免加载图片信息以加快加载和访问远程连接的设备?
提前感谢您提供任何信息和提示!
【问题讨论】:
-
github.com/nosalan/powershell-mtp-file-transfer 在这个 repo 上有一个脚本可以通过 MTP 从 android 存储复制
标签: android powershell mtp