How to Encrypt and Decrypt File and Folder Using Command Prompt

Command Prompt is a great tool that helps users manage their system such as scanning for system problems, fixing different sorts of errors, registering programs, etc. With handy command tools, we can easily update Windows, view the hardware information and even acheive encryption. Since Windows 2000, the Encrypted File System (EFS) are available for end users, enabling users to prevent files and folders from unwanted visitors with physical access to the computer. Those without a certificate who want to access your encrypted files will be prompted that they cannot access them. Here we will share a useful command tool for encrypting and decrypting files and folders with EFS in Windows 10/11.
Notice
Limitations
EFS(Encrypted File System) is not supported on Windows Home Edition.
It only supports the NTFS file system.
Cautions
Run commands with administrator privileges.
Be sure to back up your file encryption key; otherwise, you may lose access to encrypted files after reinstalling the operating system.
How to encrypt file and folder?
1. Encrypting file with the command
Step 1: Press Windows+R to open Run command and input cmd in the box. Then press Ctrl+Shift+Enter to open Command Prompt as administrator.

Step 2: Type the below command in the Command Prompt and press Enter to execute it:
cipher /e "<full path of file>"
For example:
cipher /e "G:\insg.txt"

Note: Replace the <full path of file> with the location path of the file you need to encrypt. Don't miss out the extension name of the file. You are able to use multiple directory paths to encrypt more than one files, but you must put spaces between each parameters.
The encrypted file will be marked with a lock.

2. Encrypting folder with the command
Step 1: Open Command Prompt as administrator.
Step 2: Enter the below command in the window. This command only valid for the specified folder.
cipher /e "<full path of folder>"
For example:
cipher /e "C:\Users\Raten\Desktop\New folder"

Now you will find a lock symbol on the encrypted folder.

Step 3: If you want the changes valid for all subfolders and files, enter the following command:
cipher /e /s:"<full path of folder>"
For example:
cipher /e /s:"C:\Users\Raten\Desktop\New folder"

After done, you can view the total number of files encrypted. When you open this folder again, all the subfolders and files should be marked with a lock icon on the top-right corner.

How to decrypt file and folder?
1. Decrypting file with the command
Step 1: Start Command Prompt with administrative privileges.
Step 2: Input the following command and hit Enter to run it.
cipher /d "<full path of file>"
For example:
cipher /d "G:\insg.txt"

The file is successfully decrypted when you see the OK.
2. Decrypting folder with the command
Step 1: Run Command Prompt as administrator.
Step 2: Enter the below command to decrypt the specified folder only:
cipher /d "<full path of folder>"
For example:
cipher /d "C:\Users\Raten\Desktop\New folder"

Once finished, you won't see the lock icon on the top-right corner of the folder but the lock symbol on the subfolders and files won't disappear.
Step 3: To decrypt all subfolders and files in the folder, enter the command as follows:
cipher /d /s:"<full path of folder>"
For example:
cipher /d /s:"C:\Users\Raten\Desktop\New folder"

How to find all encrypted files?
EFS ( Encrypted File System) provides protection for files that belong to the current user on all local drives. Any folders and files saved to an existing encrypted folder will automatically be encrypted by the EFS. If you have multiple user accounts on a computer, how to find all EFS encrypted files under the present account? Here's the instructions:
Step 1: Open Command Prompt as an administrator.
Step 2: Copy and paste the following command and hit Enter. All the EFS encrypted files will be displayed on the screen.
cipher /u /n /h

Bonus Tip: Finding All EFS-Encrypted Folders Using PowerShell
Step 1: Open PowerShell as an administrator.
Step 2: Enter the following command and press Enter.
Get-ChildItem -Path "C:\Users\Sou\" -Directory -Recurse | Where-Object { $_.Attributes -match "Encrypted" } | Select-Object FullName
// Replace the C:\Users\Sou\ with your actual path.
Step 3: Wait for the retrieval process to finish.