批处理脚本以查找已安装设备的驱动器号 [英] batch script to find drive letter of a mounted device
问题描述
我正在尝试编写批处理脚本来查找特定的挂载设备.我在Windows 7中.
I am trying to write a batch script to locate a particular mounted device. I'm in windows 7.
我知道该设备将具有文件夹drive:\ custom,所以我想研究所有找到具有此路径的设备的可能性
I know that the device will have the folder drive:\custom so I'm wanting to look at all possabilities to find a device with this path
这是我到目前为止所拥有的
Here is what i have so far
@echo off
setLocal Enabledelayedexpansion
for %%d in (c d e f g h i j k l m n o p q r s t u v w x y z) do (
if exist %%d:\custom (
ECHO Device Found : %%d
)
)
尽管这不起作用,但它认为每个驱动器号都存在..所以我看到每个驱动器号均显示找到设备".这是为什么?我要解决这个错误吗?如何在根目录中找到带有文件夹"custom"的驱动器号?
This doesnt work though, it thinks it exists for every drive letter.. so i see 'Device Found' for every single drive letter. Why is that? Am I going about this wrong? How can I locate the drive letter that has a folder 'custom' on the root directory?
谢谢,
斯蒂芬妮
thanks,
Stephanie
推荐答案
在路径末尾添加\
:
IF EXIST %%d:\custom\ (...)
这篇关于批处理脚本以查找已安装设备的驱动器号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!