批处理返回具有特定卷名的USB驱动器号 [英] batch that return drive letter of USB with specific volume name
本文介绍了批处理返回具有特定卷名的USB驱动器号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在批处理方面经验不足,因此需要批处理脚本的帮助.任务是,将驱动器号作为参数返回到%disk_letter%
I do not have much experience with batch an d need a help with batch script. Task is, return drive letter as parameter to %disk_letter%
想法用于搜索:
WMIC LogicalDisk,其中VolumeName ='MY_USB'获取/Format:list |查找标题="
WMIC LogicalDisk Where VolumeName='MY_USB' Get /Format:list | FIND "Caption="
结果是"Caption = G:".我需要%disk_leter%参数等于"G:"需要帮助来完成此脚本.
I have "Caption=G:" as the result. I need that %disk_leter% parameter was equal just "G:" Need help to finish this script.
谢谢!
推荐答案
在这里...
@echo off
for /F "usebackq tokens=1,2,3,4 " %%i in (`wmic logicaldisk get caption^,description^,drivetype
2^>NUL`) do (
if %%l equ 2 (
echo %%i is a USB drive.
)
)
这篇关于批处理返回具有特定卷名的USB驱动器号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文