Search code examples
powershellcmdprocesskill

How to kill all process that run under a folder?


I want to replace some files in folder, and I see that there are multiple process under the folder that prevent me from doing that.

How can I kill all process process that run under a folder?


Solution

  • Using powershell:

    1. Navigate the current powershell directory to the destination path by:

    cd "%*DestinationPath*%"

    1. Get-Process | ?{$_.path -and (test-path (split-path $_.path -leaf ))} | Stop-Process -Force