找回密码
 注册
搜索
[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
查看: 23931|回复: 7

[系统相关] 怎样根据卷标判断盘符?[同样的问题,求VBS方法]

[复制链接]
发表于 2008-9-27 17:42:20 | 显示全部楼层 |阅读模式
具体情况是这样,我用一个虚拟光驱加载一个镜像,所以这个盘符是不确定的,唯一能确定的只有光盘的卷标
我想再本地硬盘做一个批处理来调用光盘中的程序,这时候就需要通过卷标来判断虚拟光驱的盘符了

搜索了一下,没有找到这方面的知识

麻烦大侠帮忙解决一下!
多谢了!

[ 本帖最后由 lon91ong 于 2008-9-27 19:20 编辑 ]
发表于 2008-9-27 18:03:13 | 显示全部楼层
标题本来是很不错的,非要来三个“?”,画蛇添足。请楼主自觉规范一下,修改标题
  1. @echo off
  2. for /f "skip=1" %%a in ('wmic logicaldisk where "volumename='光盘卷标'" get name') do set "CDdrive=%%a"
  3. echo %CDdrive%
复制代码

[ 本帖最后由 zqz0012005 于 2008-9-27 18:05 编辑 ]
 楼主| 发表于 2008-9-27 18:30:07 | 显示全部楼层
版主我真是爱死你了
一下午帮我解决了这么多问题!

试了一下楼上的代码,感觉速度好慢,而且用到了wmic

仅仅用命令行不能实现吗?或者用VBS也可以!


还有,版主的头像是谁呀?

[ 本帖最后由 lon91ong 于 2008-9-27 19:12 编辑 ]
发表于 2008-9-27 19:43:58 | 显示全部楼层
  1. @echo off
  2. for %%a 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 (
  3.   fsutil fsinfo drivetype %%a:|findstr /i "CD">nul&&echo 光驱盘符:%%a
  4. )
复制代码
发表于 2008-9-27 20:28:07 | 显示全部楼层
  1. @echo off
  2. for %%i 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 (
  3.   vol %%i:|findstr /i "cd">nul&&echo 光驱盘符:%%i&&goto ok
  4. )
  5. :ok
  6. pause
复制代码
发表于 2008-9-27 20:33:30 | 显示全部楼层

回复 5楼 的帖子

测试结果:
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Test>type test.bat
@echo off
for %%i 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 (
  vol %%i:|findstr /i "cd">nul&&echo 光驱盘符:%%i&&goto ok
)
k

C:\Test>test.bat
The device is not ready.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
发表于 2008-9-27 21:05:48 | 显示全部楼层
原帖由 Batcher 于 2008-9-27 20:33 发表
测试结果:

我这里测试 上去的啊 用CD标测试

[ 本帖最后由 terse 于 2008-9-27 21:30 编辑 ]
发表于 2008-9-27 22:13:10 | 显示全部楼层
  如果嫌wmic慢的话,就用vol命令吧,把if语句中的system改成你想要查询的卷标就可以了,演示如下:
  1. @echo off
  2. set drivers=c d e f g h i j k l m n o p q r s t u v w x y z
  3. for %%i in (%drivers%) do (
  4.     for /f "tokens=2,3*" %%j in ('vol %%i: 2^>nul') do if /i "%%l"=="system" echo %%j:
  5. )
  6. pause
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|批处理之家 ( 渝ICP备10000708号 )

GMT+8, 2026-3-17 06:26 , Processed in 0.023577 second(s), 8 queries , File On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表