|

How To Use The Cipher Command In Windows (2026)

Cipher shows and changes the encryption of folders and files on NTFS drives, and it can also wipe the free space on a volume.

The two most used forms are cipher /e foldername to encrypt and cipher /w:C to overwrite deleted data.

This guide follows Microsoft’s cipher reference and its Cipher.exe troubleshooting article, so each switch below is documented.

Table of Contents

Cipher quick answers

I want toType this
See which files are encryptedcipher
Encrypt a foldercipher /e private
Decrypt a foldercipher /d private
Show information about encrypted filescipher /c
Overwrite deleted data on drive Ccipher /w:C
Back up my EFS certificate and keyscipher /x backupfile

What the cipher command does

Cipher displays or alters the encryption of directories and files on NTFS volumes.

Run without parameters, it shows the encryption state of the current directory and the files in it.

It works with the Encrypting File System, so it only applies to NTFS drives.

Open Command Prompt

  1. Press the Windows key and type **cmd**.
  2. Select **Command Prompt**.
  3. Type your cipher command and press **Enter**.

For a full-volume wipe or for protected folders, open Terminal as administrator first.

The cipher syntax

Microsoft lists several forms, one for each job.

FormUsed for
cipher [/e | /d | /c] [/s:] [/b] [/h] [pathname [...]]Encrypting, decrypting and viewing files
cipher /kCreating a new EFS certificate and key
cipher /r: [/smartcard]Creating a recovery agent key and certificate
cipher /u [/n]Finding encrypted files and updating keys
cipher /w:Clearing data from unused disk space
cipher /x[:efsfile] [filename]Backing up the EFS certificate and keys
cipher /yShowing the thumbnail of your current EFS certificate
cipher /adduser, /removeuser, /rekeyManaging which users and keys can open encrypted files

Check what is encrypted

Typing cipher alone lists the current folder, and Microsoft’s sample output marks each item with a letter.

An **E** in front of a name means it is encrypted, and a **U** means it is not.

The listing also tells you that new files added to a directory will not be encrypted unless the directory itself is marked.

Encrypt a folder or file

Use cipher /e followed by the folder or file name, as in Microsoft’s example cipher /e private.

The command reports each item with [OK] and a count of the files and directories that were encrypted.

Microsoft says marked directories also encrypt files that are added to them later.

Run cipher again afterward and the folder should now show an E.

Decrypt a folder or file

Use cipher /d followed by the name to decrypt the specified files or directories.

Microsoft also warns that if the parent directory is not encrypted, an encrypted file can become decrypted when it is modified.

The fix is to encrypt the parent directory together with the file.

Switches for the encrypt and decrypt forms

SwitchWhat it does
/eEncrypts the specified files or directories.
/dDecrypts the specified files or directories.
/cDisplays information about encrypted files.
/s:Applies the operation to all subdirectories of that directory.
/bStops if an error occurs, because by default cipher continues past errors.
/hIncludes files with hidden or system attributes, which are skipped by default.

Multiple directory names and wildcards are allowed, and you separate multiple parameters with spaces.

Overwrite deleted data with cipher /w

When you delete a file, its data stays on the disk because only the space is marked as available.

Until something overwrites it, low-level disk tools or recovery software can bring that data back.

The command cipher /w: clears data from the unused space on the whole volume that contains the directory you name.

Microsoft’s example for drive C is cipher /w:C.

What cipher /w does and does not touch

  • It overwrites only deallocated space, so existing files and folders are not touched.
  • The directory can be any folder on the volume, but the scope is the entire volume.
  • If the directory is a mount point or sits on another volume, all free space on that volume is cleaned.
  • Microsoft says the removal is permanent.
  • Large amounts of free space can take a long time to overwrite.

Microsoft recommends quitting all programs before you run it.

Other parameters are ignored when you use /w.

Back up your EFS certificate and key

The /x switch backs up your EFS certificate and keys to a file.

Add :efsfile to back up the certificates used to encrypt one particular file.

The /y switch shows the thumbnail of your current EFS certificate on the local computer.

The /k switch creates a new EFS certificate and key, and other parameters are ignored when you use it.

Recovery agents and key updates

The /r switch generates an EFS recovery agent key and certificate as a .pfx file plus a .cer file.

With /smartcard, it writes to a smart card instead and creates no .pfx file.

An administrator can add the .cer contents to the EFS recovery policy, then import the .pfx file to recover individual files.

The /rekey switch updates the specified files to use the currently configured EFS key.

Why cipher /w also covers encryption leftovers

Microsoft explains that when EFS encrypts a plain-text file, it first creates a temporary backup copy of that file.

That backup is deleted afterward, but like any deleted file its data stays on the disk until something overwrites it.

The free-space wipe is the documented way to clear those remnants, and Microsoft says the Cipher utility on currently supported Windows versions is designed to prevent unauthorized recovery of such data.

Add and remove users on encrypted files

SwitchWhat it does
/adduserAdds a user to the specified encrypted files, using /certhash: or /certfile:.
/removeuserRemoves a user from the specified files, and you must give the SHA1 hash of the certificate to remove with /certhash:.
/uFinds all encrypted files on local drives and updates user or recovery agent keys that have changed.
/u /nFinds encrypted files but makes no updates.

Both /adduser and /removeuser also accept /s, /b and /h along with one or more path names.

If you need to turn off drive-level protection instead, see how to turn off BitLocker device encryption.

To encrypt a removable drive, use BitLocker To Go on a USB drive.

To erase a whole disk rather than free space, read the DiskPart clean guide.

Official sources

The switches come from Microsoft’s cipher reference.

The free-space details come from Microsoft’s article on using Cipher.exe to overwrite deleted data.

Leave a Reply

Your email address will not be published. Required fields are marked *