How to Use the doscommand to determine whether the disk partition is in NTFS format

Source: Internet
Author: User

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

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.