How can I use batch to determine if a computer is using FAT32 or NTFS and is this even possible.
There's a few ways you can do this.
A primitive way is to run chkdsk
on the volume you're interested in and capture the output. Part of that output indicates whether the disk is NTFS or not. Unfortunately, that does more than what you expect and may take some time.
Similarly, you can parse the output of fsutil fsinfo volumeinfo c:\
which is something like:
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
By extracting the file system name, you could find out what you need.
A slightly less primitive way is to use VBScript with WMI to walk the device array, checking each volume that you're interested in.
The Win32_LogicalDisk
class (available in Windows 2000 onwards) has a FileSystem
attribute which indicates this and you could use the following code as a basis:
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
It looks like attempting to use an alternate file stream (file.name:strmname
) on a FAT volume fails, so how about:
@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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With