sodcalculator

10 Tech How-To

Fix Error 0x80070021 on Windows (Step-by-Step)

Guide 10-58012 · Updated · Step by step

Error 0x80070021 appears when Windows cannot access a file or folder, often during updates, backups, or app installations. It usually means a file is locked by another process, permissions are misconfigured, or system files are corrupted. This guide walks through the most effective fixes, from simple restarts to deeper system repairs.

What You’ll Need

  • Administrator access to the Windows PC
  • Patience – some steps require a full system restart
  • Optional: a USB drive if you need to create a bootable Windows installer (only for the last resort step)

Step-by-Step

  1. Restart your computer. This clears temporary file locks. Save all work, close all programs, and choose Restart from the Start menu. Try the operation that triggered the error again. If it persists, continue.
  2. Run the Windows Update Troubleshooter. Go to Settings > System > Troubleshoot > Other troubleshooters. Find “Windows Update” and click Run. Follow the prompts. This tool automatically detects and fixes common update-related issues, including locked files. Restart after it finishes and retry.
  3. Check file and folder permissions. Right-click the file or folder that triggers the error, select Properties, then the Security tab. Click Advanced, then Change next to the owner name. Type your Windows username, click Check Names, then OK. Check the box “Replace owner on subcontainers and objects” and click OK. Back on the Security tab, click Edit, select your user, and ensure “Full control” is checked. Apply and retry.
  4. Kill processes that might lock the file. Press Ctrl+Shift+Esc to open Task Manager. Look for programs like Windows Explorer, your antivirus, OneDrive, or the app you were using. Right-click any suspicious process and select End task. If Windows Explorer is listed, restart it by right-clicking it and choosing Restart instead of End task. Retry the original action.
  5. Run System File Checker (SFC). Open Command Prompt as administrator: type “cmd” in the Start menu search, right-click Command Prompt, and select Run as administrator. Type sfc /scannow and press Enter. Wait for the scan to complete (may take 10–20 minutes). If it finds corrupted files, it will repair them. Restart and retry.
  6. Run DISM to repair the system image. If SFC didn’t fix it, run DISM. In the same administrator Command Prompt, type DISM /Online /Cleanup-Image /RestoreHealth and press Enter. This can take 20–30 minutes. It downloads healthy system files from Windows Update. Restart afterward and retry your action.
  7. Clear the Windows Update cache. Open Command Prompt as administrator. Type net stop wuauserv and press Enter, then net stop bits and press Enter. Now open File Explorer and navigate to C:\Windows\SoftwareDistribution. Delete everything inside that folder (select all, press Delete). Go back to Command Prompt and type net start wuauserv then net start bits. Restart and try Windows Update again.
  8. Perform a clean boot. Type msconfig in the Start menu search and press Enter. On the Services tab, check “Hide all Microsoft services” and click Disable all. On the Startup tab, click Open Task Manager. Disable all startup items. Click OK and restart. Test the operation. If it works, a background service was causing the lock. Re-enable services in batches to find the culprit. After testing, re-enable all services and startup items.
  9. Use the Windows Media Creation Tool (last resort). If nothing else works, download the Media Creation Tool from Microsoft’s official website. Run it and choose “Upgrade this PC now.” This reinstalls Windows while keeping your files and installed apps. It takes about an hour. This fixes deep system corruption that SFC and DISM cannot.

Common Mistakes

  • Skipping the restart. Many file locks disappear after a simple reboot. Trying complex fixes first wastes time.
  • Running SFC without administrator rights. It will fail with an access denied message. Always right-click and select “Run as administrator.”
  • Deleting the entire SoftwareDistribution folder. Only delete its contents, not the folder itself. Windows recreates it automatically, but deleting the folder can cause update issues.
  • Forgetting to restart after permission changes. Permission changes sometimes require a restart to take effect fully.
  • Using a third-party “registry cleaner.” These tools can break Windows further. Stick to built-in tools.

Tips

  • Always create a system restore point before making permission changes. Search “Create a restore point” in Start, select your drive, and click Create.
  • If the error occurs during a Windows Update, make sure you have at least 10 GB of free disk space. Updates need room to stage files.
  • Disconnect external drives temporarily. Sometimes they interfere with file operations.
  • Run a disk check to rule out hard drive issues. In Command Prompt (admin), type chkdsk C: /f and restart when prompted.
  • Keep your drivers updated, especially storage and chipset drivers. Outdated drivers can cause file access errors.

Troubleshooting

If the error still appears after SFC and DISM: Run them again in safe mode. To boot into safe mode, hold Shift while clicking Restart in the Start menu. Go to Troubleshoot > Advanced options > Startup Settings > Restart, then press 4 for Safe Mode. In safe mode, run SFC and DISM again. Some locked files are inaccessible during normal boot.

If you cannot change permissions: You might be locked out of the file. Take ownership using Command Prompt. Type takeown /f "C:\full\path\to\file" /r /d y then icacls "C:\full\path" /grant administrators:F /t. Replace the path with your actual file location.

If the error occurs during a backup: Your backup software may be incompatible with the current Windows version. Check for updates to the backup tool. Also, try backing up to a different drive or folder to isolate the issue.

If the error appears when installing a specific app: Uninstall the app completely (including leftover folders in C:\Program Files and C:\ProgramData), then reinstall as administrator. Right-click the installer and select “Run as administrator.”

If the error is tied to OneDrive or cloud sync: Pause syncing, right-click the OneDrive icon in the system tray, and choose “Pause syncing.” Try the operation, then resume. If it works, move the file out of the OneDrive folder, sync, then move it back.

Frequently Asked Questions

Q: What exactly does error 0x80070021 mean?
A: It is a Windows error code that translates to “The process cannot access the file because another process has locked a portion of the file.” It means something is holding the file open, preventing Windows from reading or writing it.

Q: Can I fix this without restarting my PC?
A: Sometimes. Try killing the locking process in Task Manager or running SFC. But a restart is the simplest and most reliable first step.

Q: Will I lose my files if I use the Media Creation Tool?
A: No, choosing “Upgrade this PC now” keeps your personal files and installed applications. It only replaces Windows system files. However, it is wise to back up important data before any major repair.

Q: How long does the DISM command take?
A: Typically 20–30 minutes, but it can take longer on older hardware or slow internet connections. Do not interrupt it once started.

Q: Is this error a sign my hard drive is failing?
A: Not usually. It is more commonly caused by software locks or permission issues. However, if you also see other errors like 0x80070057 or hear unusual noises from the drive, run a disk check.

Q: Do I need to be an administrator to fix this?
A: Yes. All the fixes in this guide require administrator privileges. If your account is not an administrator, you will need to ask someone with admin rights to perform these steps.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →