How to Know Which Processes Are Using the Specified File

How to Know Which Processes Are Using the Specified File

The system will give an error when I try to delete it. Of course I know the command Stop-Process can help me kill the process. But I don't know which processes are using it. Can anybody tell me how the find the processes which are using the specified file?

PS:this is my powershell version:

4

1 Answer

1.How to Find Out Which Windows Process is Using a File (Process Explorer)

2.PowerShell method:

IF((Test-Path -Path $FileOrFolderPath) -eq $false) {
    Write-Warning "File or directory does not exist."       
}
Else {
    $LockingProcess = CMD /C "openfiles /query /fo table | find /I ""$FileOrFolderPath"""
    Write-Host $LockingProcess
}

3.WhoLockMe Explorer Extension v2.0 beta (NT-Win2K-XP) - Explorer extension which adds a right-click menu option

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Alexander Ross
Author

Alexander Ross

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.