找到可移动驱动器的数量 [英] find number of removable drives

查看:93
本文介绍了找到可移动驱动器的数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我是新手,但最近遇到了在连接本地磁盘的'n''数量的USB磁盘上运行批处理文件的问题。如果有人可以在批处理脚本文件中帮助查找附加到系统的磁盘数,请在n个磁盘中运行批处理文件。在所有可移动磁盘上运行批处理文件并退出。



感谢预期

Hi,
I am a Novice but recently had a problem of running a batch file on the ''n'' number of usb disk attached leaving the local disks. If anybody can help in
a batch script file to find the number of disk attached to the system , run the batch file in n number of disk. run the batch file on all the removable disks and exits.

Thanks in anticipation

推荐答案

基本上,这一切都是通过WMI完成的: http://en.wikipedia.org/wiki/Windows_Management_Instrumentation [ ^ ]。



In PowerShell(强烈推荐):



Basically, it all is done via WMI: http://en.wikipedia.org/wiki/Windows_Management_Instrumentation[^].

In PowerShell (highly recommended):


drives = Get-WmiObject Win32_Volume |其中{
drives = Get-WmiObject Win32_Volume | Where {


_.DriveType -eq 2}
_.DriveType -eq 2 }



这里,驱动器类型2表示可移动驱动器



在传统批次中:




Here, drive type 2 means "removable drive"

In legacy batch:

@wmic logicaldisk get volumeName, description, deviceId





添加一些代码来计算它们。



请参阅:

http://technet.microsoft.com/en-us/library/bb742610.aspx [ ^ ]

-SA


这篇关于找到可移动驱动器的数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆