How to Encrypt and Decrypt File and Folder Using Command Prompt

User Author

Achilles.H

October 27, 2022

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 all users, enabling users to prevent files and folders from unwanted visitors with physical access to the computer. Those who want to access your computer that they don’t have the right certificate, they will get access denied message. Here we will share a useful command tool for encrypting and decrypting files and folders with EFS in Windows 10/11.

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.

open command prompt

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"
encrypt file

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.

check encrypted file

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"
encrypt folder only

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

check lock icon

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"
encrypt subfolders and files

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.

check encrypted subfolders

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"
decrypt file

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"
decrypt folder only

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"
decrypt subfolders and files

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
find encrypted files