A colleague asked how to use commands to determine whether the disk is in NTFS format for further command operations, such as converting the disk format or setting file/folder security permissions.
First, you can use diskpart. It can be used as follows:
Echo list volume> t.txt & diskpart/s t.txt | find "C"> result.txt & del t.txt
Then, use the for sentence to perform segmentation judgment on the output result result.txt. However, this code looks too complex and diskpart can only run in administrator mode.
Therefore, it is unrealistic to use the diskpart command. When you use cacls to set file permissions, it is found that 1 is returned when you run on a non-NTFS disk. Therefore, you can determine whether a disk is:
Cacls C:/> NUL
If % errorlevel % = 1 echo C disk is not in NTFS format
However, the above method only applies to XP/2003, Win2000 does not have the diskpart command, and running cacls on non-NTFS returns 0, although you can use the ver command output to determine whether the system is XP/2003, however, it is difficult to determine whether the cacls command is in NTFS format in Win2000. It may be said that the cacls command output is null to judge, if the disk is in NTFS format, but does not have any security permissions, it is hard to say.
Write a WMI script (filesystem. vbs ):
On Error resume next
Const wbemflagreturnimmediately = & H10
Const wbemflagforwardonly = & H20
For each strcomputer in arrcomputers
Set ob1_miservice = GetObject ("winmgmts: //./root/cimv2 ")
Set colitems = ob1_miservice. execquery ("select * From win32_logicaldisk", "WQL ",_
Wbemflagreturnimmediately + wbemflagforwardonly)
For each objitem in colitems
Wscript. Echo objitem. Caption & "& objitem. filesystem
Next
Next
Cscript // nologon filesystem. vbs can list the file system formats of all drive letters. Except for unavailable (such as the optical drive without a cd), the fixed modifiable batch processing is as follows:
Cscript // nologo filesystem. vbs | find "C: NTFS"
If % errorlevel % = 1 echo C disk is not in NTFS format