4

我如何使用批处理来确定计算机使用的是 FAT32 还是 NTFS,这是否可能。

4

5 回答 5

7

有几种方法可以做到这一点。

一种原始方法是chkdsk在您感兴趣的卷上运行并捕获输出。该输出的一部分指示磁盘是否为 NTFS。不幸的是,这超出了您的预期,可能需要一些时间。

同样,您可以解析其输出,fsutil fsinfo volumeinfo c:\例如:

Volume Name : Primary
Volume Serial Number : 0x4f70e7b
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

通过提取文件系统名称,您可以找到所需的内容。

一种稍微不那么原始的方法是使用带有 WMI 的 VBScript 来遍历设备数组,检查您感兴趣的每个卷。

该类Win32_LogicalDisk(在 Windows 2000 及更高版本中可用)具有FileSystem指示这一点的属性,您可以使用以下代码作为基础:

Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colVols = objWMIService.ExecQuery ("select * from Win32_LogicalDisk")
For Each objVol in colVols
     MsgBox objVol.Name & " : " & objVol.FileSystem
Next
于 2011-08-09T12:07:04.157 回答
5

尝试在 FAT 卷上使用备用文件流 ( ) 似乎file.name:strmname失败了,那么如何:

@echo off
set drv=C:
set file=temp.temp

if exist %drv%\%file% del %drv%\%file%
@echo 1 > %drv%\%file%:stream
if not exist %drv%\%file% goto FAT

:NTFS
echo is NTFS
del %drv%\%file%
goto eof

:FAT
echo is FAT
goto eof

:eof
于 2011-08-09T12:23:10.263 回答
3

这是一个老问题,但这是我获取驱动器文件系统然后将其设置为变量的答案%DriveType%

替换C:为您选择的驱动器并根据使用位置使用以下命令之一:

在批处理文件中使用:

@echo off
for /f "tokens=5" %%a in ('@fsutil fsinfo volumeinfo c:^|findstr /B "File System Name : "') do (@set DriveType=%%a)
echo %DriveType%
pause

在命令提示符中使用:

for /f "tokens=5" %a in ('@fsutil fsinfo volumeinfo c:^|findstr /B "File System Name : "') do @set DriveType=%a
于 2015-08-26T17:20:01.063 回答
2

试试这个:

@echo off
SET VOLUME_LETTER=c:
fsutil fsinfo volumeinfo %VOLUME_LETTER% 2>NUL | find /I /N "NTFS">NUL

if [%ERRORLEVEL%] == [0] echo NTFS
于 2011-08-09T12:31:41.973 回答
1

另一种方法(需要管理员权限):

fltmc volumes | find ":"

这将列出所有驱动器的文件系统类型。您可以使用例如“C:”而不是“:”按驱动器过滤

于 2013-09-08T09:52:44.147 回答