File System Tools
The tools described in this section are available from either the Windows 2000 operating system CD or the Windows 2000 Resource Kit companion CD. Table 17.11 shows where on your computer to find the tools.Table 17.11 Location of File System Tools
Tool | Default Installed Location of Program |
---|---|
Cacls.exe | %SystemRoot%System32 |
Cipher.exe | %SystemRoot%System32 |
Compact.exe | %SystemRoot%System32 |
Compress.exe | C:Program FilesResource Kit |
Convert.exe | %SystemRoot%System32 |
Diruse.exe | C:Program FilesResource Kit |
Efsinfo.exe | C:Program FilesResource Kit |
Expand.exe | %SystemRoot%System32 |
Mountvol.exe | %SystemRoot%System32 |
Cacls: Displays and Modifies NTFS Access Control Lists
You can use Cacls to display or modify access control lists (ACLs) of files or folders. The syntax of Cacls is:
|
Table 17.12 follows the command syntax and describes the command switches. Table 17.12 Cacls Switches
Switch | Description |
---|---|
filename or folder | Displays ACLs. |
/t | Changes ACLs of specified files in the current folder and all subfolders. |
/e | Edits ACL instead of replacing it. |
/c | Continues on access-denied errors. |
/g user:right | Grants a specified user account access rights, such as:R (Read)C (Change [write])F (Full Control) |
/r user | Revokes a specified user account's access rights (only valid with /e). |
/p user:right | Replaces a specified user account's access rights, such as:N (None)R (Read)C (Change [write])F (Full Control) |
/d user | Denies access to a specified user account. |
/? | Displays user help. |
Wildcard characters can be used to specify more than one file in a command. You can also specify more than one user in a command, separating the user account listings with spaces.If you already have permissions set for multiple users on a folder or file and do not use the /e switch, all existing user permissions are removed and replaced by the user and permissions specified at the command line. Use the following syntax when modifying user permissions to include read, change, and full control:
|
The Cacls tool does not provide a /y switch that answers automatically with Y to the Are you sure? Y/N prompt. However, you can use the echo command to pipe the character Y as input to the prompt when you are running Cacls in a batch file. Use the following syntax to automatically answer Y:
|
IMPORTANT
Do not enter a space between the Y and the pipe symbol (|), or Cacls cannot make the permissions change.
Cipher: Displays or Alters Encryption of Files or Folders
Cipher is a command-line tool that is used to manage or display the Encrypting File System feature of NTFS. You can use it to encrypt or decrypt files and folders, and you can set switches to ignore errors and to force encryption on objects that might already be encrypted. You can also create a new encryption key. Cipher is especially useful when manipulating encryption attributes by using batch files.The syntax of Cipher is:
|
Table 17.13 describes the switches available with Cipher.Table 17.13 Cipher Switches
Switch | Description |
---|---|
/e | Encrypts the specified folders. Folders are marked so that files added afterward are encrypted. |
/d | Decrypts the specified folders. Folders are marked so that files added afterward are not encrypted. |
/s:folder | Performs the specified operation on folders in the specified folder and all subfolders. |
/a | Specifies that the operation is for files as well as folders. The encrypted file might become decrypted when it is modified if the parent folder is not encrypted. Make sure to encrypt the file and the parent folder. |
/i | Continues performing the specified operation even after errors have occurred. By default, cipher stops when an error is encountered. |
/f | Forces the encryption operation on all specified objects, even those that are already encrypted. Already-encrypted objects are skipped by default. |
/q | Reports only the most essential information. |
/h | Displays files with the hidden or system attributes. These files are omitted by default. |
/k | Create a new file encryption key for the user running Cipher. If this switch is used, all the other switches are ignored. |
pathname | Specifies a file or folder. Wildcards are acceptable. |
/? | Displays user help. |
NOTE
Used without switches, Cipher displays the encryption state of the current folder and any files it contains. You can use multiple folder names and wildcards. Include spaces between multiple switches.
Compact: Compresses and Decompresses NTFS Files and Folders
Compact is the command-line version of the real-time NTFS compression functionality used in Windows Explorer. Compact displays and alters the compression of folders and files on NTFS volumes. It also displays the compression state of folders. The syntax of Compact is:
|
Table 17.14 describes the switches available with Compact. Table 17.14 Compact Switches
Switch | Description |
---|---|
none | Displays the compression state of the current folder. |
/c | Compresses the specified folder or file. |
/u | Decompresses the specified folder or file. |
/s[:folder] | Specifies that the requested action (compress or decompress) be applied to all subfolders of the specified folder, or to the current folder if none is specified. |
/a | Displays files with the hidden or system attribute. |
/i | Ignores errors. |
/f | Forces a specified folder or file to compress or decompress. |
/q | Reports only the most essential information. |
filename | Specifies a file or folder. You can use multiple file names and wildcard characters. |
/? | Displays user help. |
The following are reasons to use this tool rather than the Windows Explorer equivalent:
You can use compact in a batch file. Using the /i switch enables you to skip files that cannot be opened when you are running in batch mode, such as files already in use by another program. If the system failed during compression or decompression when using Windows explorer, the file or folder is marked as compressed or uncompressed, even if the operation did not complete. You can force the operation to complete by using compact with the /f switch (with either the /c or /u switch).
NOTEWhen you attempt to compress a volume that is very low on free space, you might receive an error indicating that there was insufficient space to perform the action.These errors indicate that the system needs additional free space to perform a compression. The system is not designed to manipulate the data in place on the disk. Additional space is needed to buffer the user data and to possibly hold additional file system metadata. The amount of additional free space required depends on the cluster size, file size, and available space.
Compact automatically compresses or decompresses all of the files and subfolders when you change the compression state of a folder. It does not ask whether you want to change the compression state of the files or subfolders in it.
For more information about real-time compression support in NTFS, see "Volume, Folder, and File Compression" earlier in this chapter.
Compress: Compresses Files or Folders
Compress is a command-line tool that can be used to create compressed copies of one or more files, similar to popular third-party file compression tools. If the destination listed on the command line does not include a new file name for the compressed file, the file's original name is used (a new name is required to save the compressed file in the same folder as the original). You cannot work with a file that has been compressed by this tool until you have uncompressed it with the tool Expand. The compressed file appears to be corrupted if you attempt to use it. Typically, files compressed with this tool are named with the last letter of the file name extension replaced with an underscore character (_) to clearly identify the file as compressed. Many of the files on the Windows 2000 operating system CD are compressed and use this naming scheme to indicate to the user that they need to be uncompressed before they can be used. The syntax of Compress is:
|
Table 17.15 describes the switches available with Compress.Table 17.15 Compress Switches
Switch | Description |
---|---|
–r | Renames compressed files. |
–d | Updates compressed files only if out-of-date. |
-z | Types of compression used: -z—MS-ZIP compression-zx—LZX compression-zq[n]—Quantum compression and optional level, ranging from 1-7(default is 4) |
source | Specifies the source file. The asterisk (*) and question mark (?) wildcard characters can be used. |
destination | Specifies the destination file or path. The destination can be a folder. If source specifies multiple files and the –r switch is not specified, then destination must be a folder. |
/? | Displays user help. |
NOTE
Do not use Compress to compress files or folders on NTFS volumes. Instead, compress NTFS files and folders by using Compact or by setting or clearing the Compressed attribute in Windows Explorer.
Compress is a Windows 2000 Resource Kit tool. Install this tool from the Windows 2000 Resource Kit companion CD.
Convert: Converts a Volume from FAT to NTFS
Convert is a command-line tool that can be used to convert a volume formatted with FAT16 or FAT32 to NTFS. This tool performs the conversion within the existing volume without loss of data. You do not need to back up and restore the files when you use this program.You cannot convert the Windows 2000 boot volume while you are running Windows 2000, so Convert allows you to convert the volume the next time you start Windows 2000. When you convert the volume this way, Windows 2000 restarts twice to complete the conversion process. The syntax of Convert is:
|
Table 17.16 describes the switches available with Convert.Table 17.16 Convert Switches
Switch | Description |
---|---|
volume: | Specifies drive letter (followed by a colon), volume mount point, or volume name that you want to convert. |
/fs:NTFS | Specifies that you want to convert to NTFS. |
/v | Runs the tool in verbose mode. |
/? | Displays user help. |
IMPORTANT
Volumes that are converted from FAT to NTFS (rather than being initially formatted with NTFS) lack some performance benefits. Fragmentation of the MFT might occur, and on boot volumes, NTFS permissions are not applied after the volume is converted.
DirUse: Scans a Folder and Reports On Disk Space Usage
DirUse is a command-line tool that can be used to determine the actual usage of space for compressed files and folders in NTFS volumes. The syntax of the command is:
|
Table 17.17 describes the switches available with DirUse.Table 17.17 DirUse Switches
Switch | Description |
---|---|
/s | Specifies whether subfolders are included in the output. |
/v | Outputs progress reports while scanning subfolders. Ignored if /s is specified. |
/m | Displays disk usage, in megabytes. |
/k | Displays disk usage, in kilobytes. |
/b | Displays disk usage, in bytes (default). |
/c | Uses Compressed size instead of apparent size. |
/, | Uses thousand separator when displaying sizes. |
/l | Outputs overflow to log file Diruse.log. |
/* | Uses the top-level folders residing in the specified dirs. |
/q:# | Marks folders that exceed the specified size (#) with a "!". (If /m or /k is not specified, then bytes is assumed.) |
/a | Specifies that an alert is generated when specified sizes are exceeded. (The Alerter service must be running.) |
/d | Displays only folders that exceed specified sizes. |
/o | Specifies that subfolders are not checked for specified size overflow. |
folders | Specifies a list of the paths to check. |
/? | Displays user help. |
The important switch for compressed folders and files is /c, which causes DirUse to display the actual size of a compressed file or folder instead of apparent uncompressed size. For example, if your drive D is an NTFS volume, to get the disk space actually used (in megabytes) and the number of files in each of the folders, at the command prompt type:diruse /s /m /c d:To see compression information for an individual file, open Windows Explorer, right-click the file, and then click Properties.For more information about DirUse, see the Windows 2000 Resource Kit Tools Help.
NOTE
DirUse is a Windows 2000 Resource Kit tool. Install this tool from the Windows 2000 Resource Kit companion CD.
Efsinfo: Displays Information on Encrypted Files and Folders
Efsinfo is a command-line tool that can be used to display information about files and folders on NTFS volumes that are encrypted with Encrypting File System. Information about authorized users, recovery agents, and an enumeration of the encrypted files and folders on the local computer can be displayed. The syntax of the command is as follows:
|
Table 17.18 describes the switches available with Efsinfo.Table 17.18 Efsinfo Switches
Switch | Description |
---|---|
/u | Displays user information. This is the default. |
/r | Displays recovery agent information. |
/c | Displays certificate thumbnail information. |
/i | Continues performing the specified operation even after errors have occurred. By default, Efsinfo stops when an error is encountered. |
/y | Displays your current EFS certificate thumbnail on the local computer. The specified files might not be on this computer. |
/s:folder | Performs the specified operation on folders in the specified folder and all subfolders. |
pathname | Specifies a file or folder. Wildcards are acceptable. |
/? | Displays user help. |
NOTE
Efsinfo is a Windows 2000 Resource Kit tool. Install this tool from the Windows 2000 Resource Kit companion CD.
Expand: Expands Compressed Files
Expand is a command-line tool that can be used to create uncompressed copies of compressed files from your Windows 2000 Resource Kit companion CD or any file compressed by the Compress tool.The syntax of the command is:
|
Table 17.19 describes the switches available with Expand. Table 17.19 Expand Switches
Switch | Description |
---|---|
–r | Renames expanded files. |
source | Specifies the source file. The asterisk (*) and question mark (?) wildcard characters can be used. |
destination | Specifies the destination file or path. The destination can be a folder. If source specifies multiple files and the –r switch is not specified, then destination must be a folder. |
/? | Displays user help. |
Mountvol: Displays, Creates, and Deletes Volume Mount Points
Mountvol is a command-line tool that can be used to create, list, or delete volume mount points in your system. The syntax of the command is:
|
Table 17.20 describes the switches available with Mountvol.Table 17.20 Mountvol Switches
Switch | Description |
---|---|
[drive:]path | Specifies the existing NTFS folder where you want the mount point to reside. |
VolumeName | Creates a new volume mount point. Specifies either a drive letter root folder or an existing empty NTFS folder as the source of the mount point and a volume name as the target. |
/d | Removes the volume mount point from the specified folder. |
/l | Lists the mounted volume name for the specified volume mount point. |
/? or blank | Displays user help, the name, globally unique identifier (GUID), and location of the volume. |
IMPORTANT
A volume can have only one drive letter. Using Mountvol to assign a drive letter fails if the volume already has a drive letter. To avoid this problem, delete the drive letter of the volume before assigning a drive letter using Mountvol.