Fix Lock Violation Error in Windows 11
In this article
A lock violation error in Windows 11 usually means a file or folder is still open in another program, so Windows cannot move, rename, delete, or write to it. The fastest fix is to close the app that is using the file, then retry the action. If you cannot tell which program is holding the file, restarting the PC clears most locks in one step. The steps below go from the quickest, safest fixes to the deeper ones, and each is a real option in Windows 11 rather than a guess.
Note that menu labels in Windows 11 can differ slightly by version, edition, and region, so if a label looks a little different on your PC, look for the closest match.
What You'll Need
- A Windows 11 PC where you can sign in with an account that has administrator rights (needed for some steps).
- Permission to close the programs involved. Closing an app can discard unsaved work, so save anything open first.
- Access to the file or folder that is throwing the error, so you can retry the action after each fix.
Step-by-Step
- Save your work and close the obvious apps. If the error appeared while you were deleting, moving, or renaming a file, the program that created or opened it is the usual culprit. Close the document in Word, the image in your editor, the video in your player, and any File Explorer window showing that folder. Then retry the action.
- Restart the PC. A restart releases file handles held by background processes, including ones you cannot see in the taskbar. Use Start > Power > Restart rather than Shut down, since Restart fully reloads Windows. Retry the action after signing back in.
- Check for a second File Explorer window or a preview pane. Windows can lock a file if it is selected in another Explorer window, or if the preview pane is showing it. Close extra Explorer windows, and in the open window select View > Show > Preview pane to turn the preview off, then retry.
- Identify the process holding the file with Resource Monitor. Open Start, type Resource Monitor, and launch it. Go to the CPU tab, expand the Associated Handles section, type part of the file or folder name into the search box, and look at the Image column. That names the process holding the file. If it is a program you recognise and do not need, close it normally and retry.
- End the task only if you are sure. If the process has no window and will not close, open Task Manager with Ctrl+Shift+Esc, find the process on the Processes tab, right-click it, and choose End task. This can lose unsaved work in that program, so only do it for a process you recognise. Retry the file action.
- Take ownership and check permissions if the error mentions access. Right-click the file or folder, choose Properties, open the Security tab, and check whether your account has Full control. If it does not, click Edit, select your account, and tick Full control (you need administrator rights). If the ownership is wrong, use the Advanced button on the Security tab to change the owner to your account. Apply the changes and retry.
- Run a scan with Microsoft Defender. Open Windows Security from Start, go to Virus & threat protection, and run a quick scan. Malware can hold files open or block access. If a threat is found, let Defender remove it and restart the PC.
- Run the built-in troubleshooters. Go to Settings > System > Troubleshoot > Other troubleshooters and run the ones that fit, such as the Windows Update troubleshooter if the lock error appears during an update. Let it apply any fixes and retry.
- Check the disk for errors. Open File Explorer, right-click the drive, choose Properties, open the Tools tab, and click Check under Error checking. This scans the file system for problems that can cause files to stay locked. It can take a while on large drives.
- Boot into Safe Mode as a last diagnostic. Go to Settings > System > Recovery, click Restart now next to Advanced startup, then choose Troubleshoot > Advanced options > Startup Settings > Restart, and select Safe Mode. If the file action works in Safe Mode, a third-party program is causing the lock, and you can narrow it down by disabling startup apps in Task Manager.
Common Mistakes
- Deleting the file from a different location or trying a different action instead of fixing the lock. The lock stays until the holding program releases it.
- Using Shut down instead of Restart. With Fast Startup enabled, Shut down can keep some system state, so Restart is the more reliable reset.
- Ending random processes in Task Manager. Ending a system process can destabilise Windows, so only end a process you can identify from Resource Monitor.
- Changing permissions on a system folder. Taking ownership of Windows or Program Files folders can break updates and apps. Restrict permission changes to your own files.
- Ignoring the exact error text. A lock violation and an access-denied error look similar but need different fixes, so read the message before acting.
Tips
- Copy the file to a new folder and work on the copy if you need to keep moving while the original is locked.
- Close apps from the system tray as well as the taskbar; some programs keep running in the background after you close their window.
- Check whether OneDrive or another sync tool is uploading the file, since sync can briefly lock it. Wait for the sync icon to settle, then retry.
- If the lock happens on a network share, another user may have the file open. Ask them to close it, or check the share from the host PC.
- Keep Windows updated through Settings > Windows Update, since file system fixes arrive through updates.
Troubleshooting
If the error returns after a restart, the lock is coming from something that starts with Windows. Open Task Manager, go to the Startup apps tab, and disable non-essential startup items one at a time, restarting between changes, until the error stops. If it appears only during Windows Update, run the Windows Update troubleshooter and check that the drive has free space, since updates need room to stage files.
If Resource Monitor shows a system process such as System or a service holding the file, do not end it. Instead, close the program that requested the file, sign out of Windows and back in, or restart. If the file is on an external drive, safely eject and reconnect the drive, then retry.
If permissions changes are refused or greyed out, your account may not be an administrator, or the folder may be controlled by policy. Sign in with an administrator account and try again. If the file is on a drive that shows as RAW or needs formatting, stop and back up what you can before doing anything else, because formatting erases data.
Frequently Asked Questions
What does a lock violation error actually mean?
It means Windows could not complete the action because another program or process still has the file or folder open. Releasing that handle, usually by closing the program or restarting, clears it.
Will restarting always fix it?
No. A restart clears most locks, but if a program reopens the file automatically at startup, or a sync tool grabs it again, the error returns. In that case, find the holding process with Resource Monitor.
Is it safe to end a process in Task Manager?
It is safe for a program you recognise and do not need running, but you can lose unsaved work in it. Never end system processes or services you cannot identify.
Can antivirus software cause a lock violation?
Yes. A security program scanning a file can hold it briefly. Wait for the scan to finish, or check your security app's settings and activity log, then retry the action.
Does taking ownership fix every lock error?
No. Ownership and permissions fix access-denied problems. A lock violation is about a file being in use, so closing the program or restarting is the right fix first.
Why does the error appear only on files in OneDrive?
OneDrive syncs files in the background and can hold them while uploading or downloading. Let the sync finish, or pause syncing from the OneDrive icon in the taskbar, then retry.