Document Key
Windows 10 & 11 Buy license · $29.95
Windows built-in tools

How to Encrypt and Decrypt Files With the Windows cipher Command

How to use the cipher command to encrypt files and folders with EFS in Windows, decrypt them, check status and back up your certificate.

Updated 5 minute read The Document Key team

The cipher command is the command-line front end to EFS, the Encrypting File System built into Windows Pro, Enterprise and Education. To encrypt a file, open Command Prompt and run cipher /e "C:\path\to\file". To encrypt a folder and everything in it, run cipher /e /s:"C:\path\to\folder". To decrypt, use /d instead of /e. Encrypted files open normally for your Windows account and are blocked for other accounts. Before you rely on it, back up your EFS certificate with cipher /x, or a Windows reinstall can lock you out of your own files.

This guide covers the switches you will actually use, worked examples, and the limits that matter.

Before you start: requirements

  • Windows edition. EFS encryption needs Windows 10 or 11 Pro, Enterprise or Education. On Home editions, cipher /e does not work.
  • NTFS drive. EFS only works on NTFS volumes. Most internal drives are NTFS; many USB sticks use FAT32 or exFAT and cannot hold EFS files.
  • Your account. Files are encrypted for the account that runs the command. Run it while signed in as the person who should be able to open the files.

If the equivalent checkbox in File Explorer is unavailable, our guide to Encrypt contents to secure data grayed out explains the usual causes.

The cipher switches you need

CommandWhat it does
cipherLists the current folder, marking each item E (encrypted) or U (unencrypted)
cipher /eEncrypts the named files or folders; encrypted folders also encrypt new files added later
cipher /dDecrypts the named files or folders
/s:folderApplies the operation to a folder and all its subfolders
/aApplies the operation to files as well as folders
/hIncludes hidden and system files, which are skipped by default
cipher /c fileShows details about an encrypted file, including which users can open it
cipher /x pathBacks up your EFS certificate and key to a password-protected .pfx file
cipher /w:driveWipes free space on a drive; unrelated to encryption

Run cipher /? to see the full list on your version of Windows.

How to encrypt files and folders with cipher

  1. Click Start, type cmd and open Command Prompt. You do not need an administrator window for your own files.
  2. To encrypt one file, run cipher /e "D:\Private\tax-return.pdf"
  3. To encrypt a folder, its subfolders and the files inside, run cipher /e /s:"D:\Private"
  4. Check the result by running cipher /s:"D:\Private". Each item is listed with E or U.
  5. If any files still show U, run the encrypt command again with /a added, for example cipher /e /a /s:"D:\Private".

Always put paths in quotes if they contain spaces. In File Explorer, encrypted items show a small padlock on their icons.

How to decrypt with cipher

  1. Sign in as the account that encrypted the files.
  2. For one file: cipher /d "D:\Private\tax-return.pdf"
  3. For a folder and its contents: cipher /d /a /s:"D:\Private"
  4. Run cipher /s:"D:\Private" to confirm everything now shows U.

For decrypting other types of files, such as Office documents or encrypted ZIPs, see our guide on how to decrypt a file in Windows.

Back up your EFS certificate (do not skip)

EFS keys are tied to a certificate in your Windows profile. If Windows is reinstalled, the profile is deleted, or you move the drive to another PC, the encrypted files become unreadable without a backup.

  1. In Command Prompt, run cipher /x "E:\EFS-backup", using a USB drive or another safe location.
  2. Confirm the prompt and choose a strong password to protect the backup file.
  3. Cipher creates a .pfx file. Store it somewhere other than the PC, together with a note of the password.

To restore access later, double-click the .pfx file on the new installation and follow the Certificate Import Wizard. Our guide to EFS encrypted files access denied covers recovery in detail.

An administrator resetting your Windows password (as opposed to you changing it) can cut off access to EFS keys. If you share a PC, keep the certificate backup up to date.

What cipher and EFS do not protect

EFS is useful, but it is easy to overestimate:

  • It does not ask for a password. Anyone using your signed-in session can open the files.
  • It does not travel. Copy an EFS file to a FAT32 or exFAT drive, attach it to an email or upload it through a browser, and the copy is decrypted.
  • Programs running as you can read it, including malware.
  • It is not available on Home editions.

EFS is best for keeping files private from other accounts on the same PC. For a lost or stolen laptop, BitLocker is the better tool; our comparison of EFS vs BitLocker explains when to use each.

Common cipher errors and what they mean

  • A "not supported" error. Usually the drive is not NTFS, or the Windows edition does not support EFS. Check the drive format in its Properties and your edition under Settings → System → About.
  • "Access is denied." You do not have permission to modify the file, or it was encrypted by another account. Try from the account that owns the file.
  • "The process cannot access the file because it is being used by another process." Close the program that has the file open, such as Word or a PDF viewer, and run the command again.
  • Some files skipped. Hidden and system files are ignored unless you add /h, and compressed files must be uncompressed first, because NTFS compression and EFS cannot be used on the same file.

Scripting cipher for repeat jobs

Because cipher is a command, you can put it in a batch file and run it on a schedule with Task Scheduler, for example to encrypt anything new in a scans folder each evening. Note that an EFS-encrypted folder already encrypts new files saved into it, so a schedule is mainly useful for folders that receive files copied from elsewhere.

A password-based alternative

If you are on Windows Home, want files that ask for a password, or need them to stay encrypted when you email or copy them, EFS is the wrong tool. Document Key encrypts files and folders with AES-256 and a password from the right-click menu on Windows 10 and 11, including Home, and its watched folders encrypt new files automatically without any scripting. Encrypted files stay encrypted on USB drives and in cloud folders, and a recovery key replaces the certificate backup step. Document Key and EFS can also be used side by side on Pro editions.

Frequently asked questions

Does the cipher command work on Windows Home?

No. cipher /e uses EFS, which is not available on Home editions.

How do I encrypt a folder and everything in it with cipher?

Run cipher /e /s:"C:\path\to\folder" in a Command Prompt. The /s switch applies the change to the folder and its subfolders.

How do I check whether a file is encrypted?

Run cipher with no switches in the folder, or cipher followed by the file name. Encrypted items are marked with E and unencrypted items with U.

Get three guides like this every month, plus software update notices.Subscribe →