Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Import-Module NtObjectManager
Function to kill all processes which are using a locked file.
function Kill-FileLocker {
Set-NtTokenPrivilege SeDebugPrivilege | Out-Null
Use-NtObject($file = Get-NtFile $Path -Win32Path -Access ReadAttributes) {
foreach($id in $file.GetUsingProcessIds()) {
Use-NtObject($p = Get-NtProcess -ProcessId $id -Access Terminate) {
Write-Host "Killing process $p"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.