密码

显示或更改 NTFS 卷上的目录和文件的加密。 If used without parameters, cipher displays the encryption state of the current directory and any files it contains.

Syntax

cipher [/e | /d | /c] [/s:<directory>] [/b] [/h] [pathname [...]]
cipher /k
cipher /r:<filename> [/smartcard]
cipher /u [/n]
cipher /w:<directory>
cipher /x[:efsfile] [filename]
cipher /y
cipher /adduser [/certhash:<hash> | /certfile:<filename>] [/s:directory] [/b] [/h] [pathname [...]]
cipher /removeuser /certhash:<hash> [/s:<directory>] [/b] [/h] [<pathname> [...]]
cipher /rekey [pathname [...]]

Parameters

Parameters Description
/b 如果遇到错误,则中止。 By default, cipher continues to run even if errors are encountered.
/c 显示有关加密文件的信息。
/d 解密指定的文件或目录。
/e 加密指定的文件或目录。 将标记目录,以便之后添加的文件将被加密。
/h 显示具有隐藏属性或系统属性的文件。 默认情况下,这些文件不会加密或解密。
/k 创建用于加密文件系统(EFS)文件的新证书和密钥。 If the /k parameter is specified, all other parameters are ignored.
/r:<filename> [/智能卡] 生成 EFS 恢复代理密钥和证书,然后将其写入 .pfx 文件(包含证书和私钥),以及一个.cer文件(仅包含证书)。 If /smartcard is specified, it writes the recovery key and certificate to a smart card, and no .pfx file is generated.
/s:<directory> Performs the specified operation on all subdirectories in the specified directory.
/u [/n] 查找本地驱动器上的所有加密文件。 If used with the /n parameter, no updates are made. If used without /n, /u compares the user's file encryption key or the recovery agent's key to the current ones, and updates them if they have changed. This parameter works only with /n.
/w:<directory> 从整个卷上可用未使用的磁盘空间中删除数据。 If you use the /w parameter, all other parameters are ignored. 指定的目录可以位于本地卷中的任何位置。 如果它是装入点或指向另一卷中的目录,则会删除该卷上的数据。
/x[:efsfile] [<FileName>] 将 EFS 证书和密钥备份到指定的文件名。 If used with :efsfile, /x backs up the user's certificate(s) that were used to encrypt the file. 否则,将备份用户的当前 EFS 证书和密钥。
/y 在本地计算机上显示当前的 EFS 证书缩略图。
/adduser [/certhash:<hash> /certfile:<filename>]
/rekey 更新指定的加密文件以使用当前配置的 EFS 密钥。
/removeuser /certhash:<hash> 从指定文件中删除用户。 The Hash provided for /certhash must be the SHA1 hash of the certificate to remove.
/? 在命令提示符下显示帮助。

Remarks

  • 如果未加密父目录,则修改文件时,加密文件可能会解密。 因此,加密文件时,还应加密父目录。

  • 管理员可以将.cer文件的内容添加到 EFS 恢复策略,以便为用户创建恢复代理,然后导入 .pfx 文件以恢复单个文件。

  • 可以使用多个目录名称和通配符。

  • 必须在多个参数之间放置空格。

Examples

若要显示当前目录中每个文件和子目录的加密状态,请键入:

cipher

Encrypted files and directories are marked with an E. Unencrypted files and directories are marked with a U. For example, the following output indicates that the current directory and all its contents are currently unencrypted:

Listing C:\Users\MainUser\Documents\
New files added to this directory will not be encrypted.
U Private
U hello.doc
U hello.txt

若要在上一示例中使用的专用目录上启用加密,请键入:

cipher /e private

以下输出显示:

Encrypting files in C:\Users\MainUser\Documents\
Private             [OK]
1 file(s) [or directorie(s)] within 1 directorie(s) were encrypted.

The cipher command displays the following output:

Listing C:\Users\MainUser\Documents\
New files added to this directory will not be encrypted.
E Private
U hello.doc
U hello.txt

Where the Private directory is now marked as encrypted.