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