【发布时间】:2012-02-29 15:35:01
【问题描述】:
我一直在编写一个小命令脚本,它将在文本文件中为我提供运行它的任何 Windows 系统的驱动器布局。它目前在 win7 和 Server2008 中工作,但无法在 WinXP 中提供完整信息。我不知道为什么。
@echo
setlocal enabledelayedexpansion
set drive=
rem wscript //NoLogo //B %~dp0system_profile.vbs
set textfile=%~dp0system_profile.txt
echo Drive Information >> "%textfile%"
echo ----------------- >> "%textfile%"
for /f "usebackq tokens=1*" %%a in (`fsutil fsinfo drives ^| find ":"`) do (
if /i "%%a" NEQ "Drives:" (
set "drive=%%a"
) ELSE (
set "drive=%%b"
)
set drive=!drive:\=!
for %%D in (!drive!) do (
for /f "usebackq tokens=1* delims=\- " %%A in (`fsutil fsinfo drivetype %%D`) do (
set type=%%B
)
set type=!type:~0,-6!
for /f "usebackq tokens=2*" %%R in (`subst 2^>nul ^| findstr /i /b "%%D"`) do set type=SUBST : %%S
echo: >> "%textfile%"
echo:%%D !type! >> "%textfile%"
if /i "!type!" EQU "Fixed" (
echo:fsutil fsinfo volumeinfo %%D >> "%textfile%"
fsutil fsinfo volumeinfo %%D >> "%textfile%"
)
)
)
pause
编辑: Win7 和 Win Server 2008 R2 的输出:
C: Fixed
Volume Name : OS
Volume Serial Number : 0x4e24ac66
Max Component Length : 255
File System Name : NTFS
Supports Case-sensitive filenames
Preserves Case of filenames
Supports Unicode in filenames
Preserves & Enforces ACL's
Supports file-based Compression
Supports Disk Quotas
Supports Sparse files
Supports Reparse Points
Supports Object Identifiers
Supports Encrypted File System
Supports Named Streams
Supports Transactions
Supports Hard Links
Supports Extended Attributes
Supports Open By FileID
Supports USN Journal
D: Fixed
Volume Name : New Volume
Volume Serial Number : 0x490067a
Max Component Length : 255
File System Name : NTFS
Supports Case-sensitive filenames
Preserves Case of filenames
Supports Unicode in filenames
Preserves & Enforces ACL's
Supports file-based Compression
Supports Disk Quotas
Supports Sparse files
Supports Reparse Points
Supports Object Identifiers
Supports Encrypted File System
Supports Named Streams
Supports Transactions
Supports Hard Links
Supports Extended Attributes
Supports Open By FileID
Supports USN Journal
E: CD-ROM
F: CD-ROM
G: CD-ROM
XP 的输出:
Drive Information
-----------------
C: Fixed
D: CD-ROM
E: CD-ROM
F: Fixed
N: Remote/Network
T: Remote/Network
我现在正在获取 XP 中第一个固定驱动器的详细信息,但第二个出现错误。我在上面的脚本中添加了一行来回显它正在使用的命令,它看起来是正确的。我可以将文本文档中的命令复制/粘贴到命令窗口中,它可以工作。但是,现在真正的问题是 Win7 PC 的反应。这是新的输出:
XP 输出:
C: Fixed
fsutil fsinfo volumeinfo C:
Volume Name :
Volume Serial Number : 0xa4728da7
Max Component Length : 255
File System Name : NTFS
Supports Case-sensitive filenames
Preserves Case of filenames
Supports Unicode in filenames
Preserves & Enforces ACL's
Supports file-based Compression
Supports Disk Quotas
Supports Sparse files
Supports Reparse Points
Supports Object Identifiers
Supports Encrypted File System
Supports Named Streams
D: CD-ROM
E: CD-ROM
F: Fixed
fsutil fsinfo volumeinfo F:
Error: The filename, directory name, or volume label syntax is incorrect.
Win7 输出:
Drive Information
-----------------
C: Fixe
D: Fixe
E: CD-RO
F: CD-RO
G: CD-RO
H: Fixe
【问题讨论】:
-
您能否编辑您的问题以添加有关您所面临问题的更多详细信息?您看到的具体问题是什么?
标签: command-line batch-file cmd