Using in PowerShell, how can I check if an application is locking a file?
I like to check which process/application is using the file, so that I can close it.
You can do this with the SysInternals tool handle.exe. Try something like this:
PS> $handleOut = handle PS> foreach ($line in $handleOut) { if ($line -match 'S+spid:') { $exe = $line } elseif ($line -match 'C:\Windows\Fonts\segoeui.ttf') { "$exe - $line" } } MSASCui.exe pid: 5608 ACMEhillr - 568: File (---) C:WindowsFontssegoeui.ttf ...
1.4m articles
1.4m replys
5 comments
57.0k users