今天才发现可以用fsutil来作本机信息查询,命令够强悍。
这段代码还可以改造一下,不用生成临时文件:
@echo off
setlocal enabledelayedexpansion
for /f "skip=1 tokens=1,2 delims=\" %%a in ('fsutil fsinfo drives^|find /v ""') do (
set aa=%%a
set aa=!aa:~-2!
for %%i in (!aa!) do fsutil fsinfo drivetype %%i
)
pause
另外,你的代码存在的问题如下:
1、delims=驱动器 是不正确的分隔语句
2、if not defined aa (set aa=%%b) else set aa=!aa!;%%a,格式应该是if not something (set1) else (set2),并且set的内容写得也有问题:比如,我在最开始加一句 set aa=1,问题立马出现;
Last edited by namejm on 2006-9-1 at 15:51 ]
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:
@echo off
setlocal enabledelayedexpansion
for /f "skip=1 tokens=1,2 delims=\" %%a in ('fsutil fsinfo drives^|find /v ""') do (
set aa=%%a
set aa=!aa:~-2!
for %%i in (!aa!) do fsutil fsinfo drivetype %%i
)
pause
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 ]