# Graceful stop (sends close signal) Stop-Process -Id 8764 Stop-Process -Id 8764 -Force
Run this PowerShell one-liner to find which process is locking C:\path\to\your\file.pdf : powershell unlock file
function Test-FileLock { param([string]$FilePath) try { $file = [System.IO.File]::Open($FilePath, 'Open', 'Read', 'None') $file.Close() return $false # File is not locked } catch { return $true # File is locked } } Test-FileLock "C:\locked.docx" # Graceful stop (sends close signal) Stop-Process -Id
# Force close all handles to a specific file (use with extreme caution!) & "C:\path\to\handle64.exe" -accepteula -c "C:\path\to\file.pdf" -y The -y flag suppresses confirmation. This immediately rips the lock away from the owning process. The process may crash or lose unsaved data, but the file will be unlocked. While tools like LockHunter or Process Explorer can
While tools like LockHunter or Process Explorer can solve this, what if you want a native, scriptable solution? Enter . While it lacks a dedicated Unlock-File cmdlet, you can combine several techniques to identify and release locked files.
& "C:\path\to\handle64.exe" -accepteula "C:\path\to\your\file.pdf" The output will look like: notepad.exe pid: 8764 type: File C:\path\to\your\file.pdf
Always save your work before force-unlocking files. A forced handle close is like unplugging a hard drive—it works, but data loss is possible.