PowerShell

From wiki.kungfootek.net
Jump to navigation Jump to search

Find all open files of type. Produces executable commands to close the open files it finds.

$commands = ((c:\handle <TYPE>) -match 'pid') -replace  '^.*pid:\s*([0-9]+).*File\s*([0-9A-F]+).*$', 'c:\handle.exe -c $2 -p $1 -y'


Find all open files of type and closes all the files it finds.

$commands = ((c:\handle <TYPE>) -match 'pid') -replace  '^.*pid:\s*([0-9]+).*File\s*([0-9A-F]+).*$', 'c:\handle.exe -c $2 -p $1 -y'
foreach ($I in $commands) { 
write-host $I

$output = (INVOKE-EXPRESSION  "$I")
}

For fun, leave <type> blank and run as administrator. :) Save all your work first, and NEVER do on a production machine.