What if the ERROR_LOCK_VIOLATION error happens? In this post, Partition Magic reveals the answer and offers you several troubleshooting methods. If you also encounter ERROR_LOCK_VIOLATION 33 (0x21), try the methods offered in this tutorial.
About ERROR_LOCK_VIOLATION
The ERROR_LOCK_VIOLATION error can happen to Windows 11, Windows 10, Windows 7, Windows Vista, Windows Server 2008, and Windows Server 2008 R2. It usually comes along with the error message “The process cannot access the file because another process has locked a portion of the file”.
When the ERROR_LOCK_VIOLATION error occurs, an application or driver silently skips reading some regions of a file. Besides, this issue can lead to various other problems. For instance:
- An antivirus product may not detect an infected file.
- An application or driver may not access the file correctly.
- An application may report a problem that affects a file. This issue most likely occurs when another application like an on-demand scanner is enumerating and scanning large collections of files simultaneously. For example, the application may report that the file format is bad or corrupted.
What causes ERROR_LOCK_VIOLATION? According to user reports, this issue is mainly caused by a bug in Windows file systems. The bug causes the file to get cached if an I/O on a non-cached handle doesn’t pass byte range lock checks.
If so, the present file pointer may be modified even if the I/O fails and prompts an ERROR_LOCK_VIOLATION error. How to get rid of the ERROR_LOCK_VIOLATION issue on a computer? This post summarizes several methods. You can try them one by one until the issue is solved.
Basic Troubleshooting Ways
Before starting to apply the methods in the post, you’d better try these basic fixes. Some users report that these tricks sometimes work for the issue.
- Make a copy of the source file: Create a copy of the source file in a different directory and access the file with the relevant software.
- Restart the PC: Sometimes, a restart may solve the problem.
- Close all running applications in the background: This operation can remove any software conflict, fixing the ERROR_LOCK_VIOLATION error.
- Disable antivirus temporarily: Turn off real-time protection in Windows Settings or disable third-party antivirus software on the PC to see if ERROR_LOCK_VIOLATION disappears.
If the above tricks don’t work, apply the following troubleshooting methods. They are more complicated but effective. Detailed steps and even screenshots are offered to you. Simply follow the given instructions to complete the operation.
#1: Use the Sysinternals Process Explorer Tool
Task Manager sometimes can’t stop conflicting apps completely. So, ERROR_LOCK_VIOLATION 33 (0x21) still appears even though you have closed some of them. In this case, use the Sysinternals Process Explorer Tool to close these conflicting apps.
Step 1: Download Process Explorer from Microsoft’s official website.
Step 2: Extract the zip file and run the setup file. According to your system architecture, choose the suitable setup file to run. If your computer is 32-bit, run the procexp.exe file. If it’s a 64-bit computer, run the procexp64.exe file.
Step 3: Accept the license terms and follow the prompted instructions to complete the installation.
Step 4: Type the complete file name with the extension in the <Filter by name> field and hit Enter. After a while, a list of conflicting processes will be displayed.
Step 5: If you don’t see anything, press Ctrl + Shift + F keys simultaneously to open the Process Explorer Search box.
Step 6: Type the problematic file name in the Handle or DLL substring field and click Search.
Step 7: Wait for the appearance of the conflicting apps and remember them. Back to the home screen, right-click on the faulty app, and click Kill Process. Repeat this operation to kill all listed conflicting apps.
#2: Perform a Clean Boot
You can perform a clean boot to avoid the interference of third-party apps. This may help you get rid of the ERROR_LOCK_VIOLATION error. This method has been proven to be useful by some users. You can have a try.
Step 1: Open the Run window, type msconfig, and click OK.
Step 2: Navigate to the Services tab, check the Hide all Microsoft Services option, and click Disable all.
Step 3: Tap on the Startup tab and click the Open Task Manager link.
Step 4: Disable all active startup processes except for drivers like Bluetooth, Realtek HD Audio, etc. To do that., right-click on the process and click Disable. Repeat the process until all the unnecessary startup processes are disabled.
Step 5: Go back to the Services tab of System Configuration and hit the Apply button.
Step 6: Restart the computer and check if the ERROR_LOCK_VIOLATION error is solved. If yes, re-enable third-party services one by one until the issue occurs again. Then remove the service.
#3: Run SFC and DISM Scans
Missing or corrupt system files are also responsible for ERROR_LOCK_VIOLATION 33 (0x21). So, it’s recommended to run SFC or DISM scans when you receive the discussed error.
Step 1: Type cmd in the search box and then click Run as administrator under the displayed Command Prompt app.
Step 2: In the elevated User Account Control window, click Yes to confirm the operation.
Step 3: Type sfc /scannow and hit Enter to execute the command.
Step 4: If you see either of the following results, you don’t need to do anything.
- No integrity violations found.
- Integrity violations found and repaired.
Nevertheless, you should continue to run DISM if you see the following message.
Integrity violations found buy some could not be repaired.
To run DISM, please refer to these steps.
- Run Command Prompt as administrator again.
- In the Command Prompt window, copy and paste the command and hit Enter.
dism /online /cleanup-image /restorehealth
#4: Check Hard Drive for Errors
ERROR_LOCK_VIOLATION often happens due to file system errors. You should also check the hard drive for file system errors when the ERROR_LOCK_VIOLATION error occurs. As an HDD/SSD health checker, MiniTool Partition Wizard is strongly recommended.
It helps you perform HDD/SSD health checks with ease. For instance, it can find if your hard drive has bad sectors and file system errors. As a comprehensive partition manager, it also allows you to partition hard drives, convert MBR to GPT, clone Windows 10 to SSD, clone a hard drive, recover data from hard drives, etc.
Now, download and install MiniTool Partition Wizard on your computer. Then run it to see if your hard drive has file system errors.
MiniTool Partition Wizard FreeClick to Download100%Clean & Safe
Step 1: Run into the main interface of MiniTool Partition Wizard.
Step 2: Right-click on the C drive and hit Check File System on the context menu. Alternatively, click on the C drive and hit Check File System on the left panel.
Step 3: In the prompted window, choose Check only (Do not fix detected errors.) and click the Start button. Wait for the finish of the scan process.
Step 4: Repeat the file system checking process on other partitions on the drive.
#5: Modify File Security Permissions
You can change file security permissions if the ERROR_LOCK_VIOLATION error occurs in Workgroup/Homegroup network, shared drive, or non-administrator Windows account. To do that, follow these steps.
Step 1: Move to the problematic file, right-click on that file, and choose Properties.
Step 2: In the Properties window, tap on the Security tab, click on the target user under Group or user names, and hit the Edit button.
Step 3: In the next window, choose the same user name, and checkmark all the boxes under Allow.
Step 4: Click Apply > OK to save changes.
#6: Repair Hardware/Driver/Firmware Issues
The ERROR_LOCK_VIOLATION 33 (0x21) can also result from hardware, driver, or firmware issues. For instance, it’s likely that the disk drive isn’t installed appropriately. If so, power off the computer and open the PC case. Unplug the power and data cable from the HDD or SSD.
If it’s an NVMe M.2 SSD chip, remove it from its PCIe slot. Connect the cables back to the hard drive or solid-state drive. For the NVMe chip, reseat it appropriately. Turn on the PC and check if the issue appears. Additionally, keep SATA HDD drivers up to date. You can update drivers by following these steps.
Step 1: Right-click the Start button to open the Start menu. Then click Device Manager from it.
Step 2: Expand Disk drives, right-click the disk driver, and choose Update driver.
Step 3: Select Search automatically for drivers or Browse my computer for drivers.
Step 4: Follow the on-screen instructions to finish the operation.
#7: Update Windows OS to the Latest Version
As you might know, Microsoft keeps releasing new updates. These updates usually contain bug fixes or add new features based on previous versions. Hence, a lot of users update Windows OS to the latest version to get rid of errors like ERROR_LOCK_VIOLATION.
You can also fix the ERROR_LOCK_VIOLATION error by updating the Windows OS. For that, follow the steps below.
Step 1: Open Settings by pressing the Windows and I keys.
Step 2: Click Update & Security > Windows Update.
Step 3: Hit Check for updates under Windows Update. If there are available updates, they will be listed in this section.
Step 4: Click the Download and install button to get the update installed.
If Windows Update is not working, manually download updates from the Microsoft Update Catalog. Then follow the prompted instructions to install it.
Bottom Line
Up to now, this post has collected the symptoms, causes, and troubleshooting methods of the ERROR_LOCK_VIOLATION error. Simply put, this is a full guide to ERROR_LOCK_VIOLATION. If you encounter any issues while using MiniTool Partition Wizard, contact us by sending an email via [email protected]. We will make a reply as soon as possible.