中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-10 15:59
47,811 topics / 349,897 posts / today 0 new / 48,255 members
DOS批处理 & 脚本技术(批处理室) » Check the local disk and determine its type
Printable Version  2,334 / 6
Floor1 9527 Posted 2006-09-01 14:27
银牌会员 Posts 438 Credits 1,185 From 北京
@echo off
setlocal enabledelayedexpansion
fsutil fsinfo drives>tmp.txt
for /f "skip=1 tokens=1,2 delims=驱动器 " %%a in ('find /v "" ^<tmp.txt') do (
if not defined aa (set aa=%%b) else set aa=!aa!;%%a
)
for %%i in (%aa%) do fsutil fsinfo drivetype %%i
del tmp.txt

Newcomer, please ask for advice from seniors...
Test environment WIN XP SP2
Floor2 namejm Posted 2006-09-01 15:09
荣誉版主 Posts 1,737 Credits 5,226 From 成都
Today I just found out that fsutil can be used for local information query, and the command is quite powerful.

This code can also be improved, without generating temporary files:


In addition, the following problems exist in your code:

1. delims=驱动器 is incorrect for separating statements
2. if not defined aa (set aa=%%b) else set aa=!aa!;%%a, the format should be if not something (set1) else (set2), and the content of set is also written incorrectly: for example, if I add a sentence set aa=1 at the beginning, the problem immediately occurs;

[ Last edited by namejm on 2006-9-1 at 15:51 ]
Floor3 NaturalJ0 Posted 2006-09-01 17:23
银牌会员 Posts 533 Credits 1,181
Learned a new command...
Floor4 vkill Posted 2006-09-01 17:25
金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽
Take it, I'll use it soon these days
Floor5 namejm Posted 2006-09-01 22:03
荣誉版主 Posts 1,737 Credits 5,226 From 成都
fsutil fsinfo drives^|find /v "" This sentence is a bit strange. According to the general understanding, most people might not think of using find /v "" to filter, and just use fsutil fsinfo drives directly. However, if there is no statement after the pipe symbol in the code, it will only display the information of the first disk partition. I can't figure it out.
Floor6 9527 Posted 2006-09-03 00:05
银牌会员 Posts 438 Credits 1,185 From 北京
It's not eerie, but because the result obtained by fsutil fsinfo drives has spaces in the middle, but it represents the function of carriage return or line feed, so you only get the information of the first partition.
Floor7 qq43142691 Posted 2007-05-23 17:53
中级用户 Posts 152 Credits 326
@echo off
:: code by 3742668 2006-12-6 CMD@XP
set /p x=Enter drive letter:
for /f "skip=1" %%i in ('wmic logicaldisk where "deviceid='%x%:'" get Description 2^>nul') do set type=%%i
if not defined type set type=This drive does not exist!
echo The type of %x%: drive is: %type%
pause>nul
goto :eof
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023