Я работал над небольшим командным сценарием, который даст мне расположение дисков любой системы 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.Вот новый вывод:
Выход 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