0X80030020

Fix STG_E_SHAREVIOLATION (0x80030020) fast

Another program has this file open. Close the app or use Process Explorer to find and kill the lock. Real fix is simpler than you think.

You're stuck because another program won't let go

I know the feeling. You're trying to move, delete, or save a file and Windows hits you with STG_E_SHAREVIOLATION (0x80030020). Feels like the computer is fighting you. It's not. It's just that something else has that file open, and Windows won't let two programs stomp on each other's toes. The fix is straightforward—let's dig that other program out.

The real fix: find and close the offender

Skip the reboot. Skip the safe mode dance. Nine times out of ten, the culprit is obvious once you look.

  1. Check running programs. Look in the system tray (bottom-right corner of your screen). Is there an app that might be using your file? Like Notepad with a text file open, a Word document, a PDF viewer, a media player, or even a backup tool. Close each one manually. Try your operation again.
  2. Still stuck? Download Process Explorer. Go to Microsoft's Sysinternals site and grab Process Explorer. Unzip it (no install needed). Run procexp64.exe as administrator (right-click → Run as administrator).
  3. Find the lock. In Process Explorer, press Ctrl+F to open the Find Handle or DLL window. Type the name of your problem file (or just part of it) and hit Search. Process Explorer will show you exactly which process has a handle on that file. It might be something you'd never guess—like explorer.exe or a background antivirus scanner.
  4. Kill the handle. In the search results, right-click the handle entry and choose Close Handle. Confirm the warning. That's it. The lock is released. Go back and try your file operation again. It should work now.

If you prefer command-line tools, use handle.exe from the same Sysinternals suite. Open a command prompt as administrator, run:

handle.exe -a -u "C:\path\to\your\file.txt"

It will print the process ID and name. Then run:

handle.exe -c 1234 -y

Replace 1234 with the actual handle number from the output. The -y flag skips the confirmation prompt.

Why this happens

Windows uses a system called share mode when a program opens a file. When an app opens a file, it specifies what kind of access it wants (read, write, delete) and what it will allow others to do. If program A opens a file with exclusive write access (denying all sharing), and program B tries to open the same file for writing, Windows slaps program B with STG_E_SHAREVIOLATION. It's not a bug—it's a safety feature. Without it, two apps could corrupt each other's data. The most common real-world trigger: you have a Word document open in Word, and you try to overwrite it from a script or another instance of Word. Or you're trying to delete a folder while Windows Explorer has a thumbnail preview open inside it.

Less common variations of the same issue

Sometimes the lock isn't from a visible program. Here's what else can cause it:

  • Windows Search Indexer. If you're working inside your Documents or Desktop folder, SearchIndexer.exe might have a handle on the file. Use Process Explorer to find and close it. It will restart automatically on the next file change.
  • Antivirus real-time scanning. Windows Defender or third-party AV can hold files briefly while scanning. If you're getting the error repeatedly, try disabling real-time protection temporarily (you'll re-enable it right after). Defender: Start → Windows Security → Virus & threat protection → Manage settings → Real-time protection → Off. Test your operation, then turn it back on.
  • Windows Photo Viewer or Media Player. If the file is an image or video, Windows might keep a thumbnail cache lock. Open Task Manager, find any PhotoViewer.dll or wmplayer.exe processes, end them, then retry.
  • Network share locks. If the file is on a network drive, another user's open handle can cause this from your side. Use openfiles in an admin command prompt: openfiles /query /v to see remote locks. The admin on the server can disconnect them.
  • Pagefile or memory-mapped files. Some programs map files directly into memory (like database engines or large image editors). Even after you close the app, the lock can persist for a few seconds. Wait 10 seconds and try again.

How to stop this from happening again

You can't prevent every share violation—sometimes you just need to edit a file while another app has it open. But you can reduce the odds:

  • Close apps before moving files. Get in the habit of closing Word, Excel, Notepad, and media players before you reorganize folders. It's a small habit that saves headaches.
  • Use a file unlocker. Keep Process Explorer on your desktop or a USB stick. It's free, portable, and Microsoft signed it. When the error pops up, you're seconds away from the fix.
  • Check for antivirus exclusions. If the file is in a folder you modify often (like a temp folder or a game save directory), add that folder to your antivirus exclusion list. This stops real-time scanning from locking files.
  • For network shares, use proper permissions. If multiple people work on the same file, consider using a document management system or version control (like Git for code). Or at least agree on who works on what and when.

That's it. Close the lock, get back to work. You won't see that error again unless another app gets grabby. When it does, you know the drill.

Related Errors in Hardware – Hard Drives
0XC00D1B68 Fix NS_E_VIDEODRIVER_UNSTABLE (0XC00D1B68) Capture Error 0X00000087 ERROR_IS_SUBSTED (0X00000087) – What It Means & How to Fix 0XC0210000 Fix 0xC0210000: BitLocker locked volume on boot Cluster quorum loss detected Storage Cluster Quorum Loss: Real Fixes That Work

Was this solution helpful?

EP
Erropedia Team
Tech Support Editors
The Erropedia editorial team researches and documents real-world tech errors from across Windows, Linux, macOS, networking, databases, cloud platforms, and more. Every solution is reviewed for accuracy and updated as software and systems evolve.