How To Lock File And Folder Using Command Prompt (CMD) In Windows 10

How to lock & unlock folder using CMD 100 % useful 2017 - YouTube



Lock the File Using Cmd

 
Step 1
 
From the Start menu, open the Run dialog box or you can Press the "Window + R" key to open the RUN window.
 
Step 2
 
Type "cmd" and click on the OK button.
 
Step 3
 
To lock a file, type the command given below into the command prompt and press Enter Key.  
 
cacls <File Path> /P everyone:n
 
For example: To lock the "noida_chapter.txt" file, run the command as, cacls E:\new\c#corner\noida_chapter.txt /P everyone:n, where n represents the user's access right to none.
 
lock any file
 
Note: After Locking the file using cmd, when you just want to open the file it shows the warning message as below.
 
warning message
 

Unlock the File Using Cmd

 
To unlock a file, type the command given below into the command prompt and press the Enter Key.
 
cacls <File Path> /P everyone:f
 
For example: To unlock the "noida_chapter.txt" file, run the command as, cacls E:\new\c#corner\noida_chapter.txt /P everyone:f, where f represents the user's access right to full control.
 
unlock using cmd
 

Lock the Folder Using Cmd

 
Step 1
 
From the Start menu, open the Run dialog box or you can Press the "Window + R" key to open the RUN window.
 
Step 2
 
Type "cmd" and click on the OK button.
 
Step 3
 
To lock a folder, type the command given below into the command prompt and press Enter Key.
 
cacls <Folder Path> /P everyone:n
 
For example: To lock the "c#corner" folder, run the command as, cacls E:\new\c#corner /P everyone:n, where n represents the user's access right to none
 
lock a folder using cmd
 
Note: After Locking the folder using cmd, when you just want to open the folder it shows the warning message as below.
 
warning message
 

Unlock the Folder Using Cmd 

 
To unlock a folder, type the command given below into the command prompt and press Enter Key.
 
cacls <Folder Path> /P everyone:f
 
For example: To unlock the "c#corner" folder, run the command as, cacls E:\new\c#corner /P everyone:f, where f represents the user's access right to full control.
 
unlock using cmd
 

Conclusion

 
By following any of the above methods, you can lock or unlock any file and folder using Command Prompt (Cmd) in Windows 10.
 
I hope you enjoyed this article. Follow C# Corner to learn more new and amazing things about Windows 10.
 
Thanks for reading this article.

Comments