用于检查锁定文件的应用程序的 PowerShell 脚本? [英] PowerShell script to check an application that's locking a file?

查看:28
本文介绍了用于检查锁定文件的应用程序的 PowerShell 脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 PowerShell 中,如何检查应用程序是否锁定文件?

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.

推荐答案

您可以使用 SysInternals 工具 handle.exe.尝试这样的事情:

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
...

这篇关于用于检查锁定文件的应用程序的 PowerShell 脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆