Stop-Process -Name explorer -Force Start-Process explorer.exe You know the lock is caused by Explorer (e.g., an image or video file preview stuck open). 2. Finding the Culprit: Identifying the Locking Process PowerShell can't directly break a lock without help, but it can tell you who has the lock. For this, we use the Handle tool from Sysinternals (Microsoft’s official utility suite).
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. powershell unlock file
Few things are as frustrating as trying to delete, move, or edit a file, only to be met with the error: "The action cannot be completed because the file is open in another program." Stop-Process -Name explorer -Force Start-Process explorer