为什么我无法删除 Windows Server 2008 中的文件“favicon.ico”?

为什么我无法删除 Windows Server 2008 中的文件“favicon.ico”?

我已将文件favicon.ico从一个网站文件夹复制到 Windows 2008 中的另一个网站文件夹。

现在我无法删除此文件,即使以管理员身份也无法在安全选项卡中更改其所有者。

我如何才能重新获得访问权限?

答案1

我发现Sysinternals 句柄成为实现这些目的的便捷(且免费)工具。

C:\path\to\handle.exe c:\path\to\favicon.ico

但是,handle.exe 仅适用于本地句柄,并且它不会告诉谁打开了文件。此 VBS 脚本找出谁打开了文件,并且可以检查远程服务器上的文件:

' WhosGotItOpen.vbs
strServername = "."         ' A dot is the same as current computer.
                            ' If you want to check remote server, replace dot with the name of the server.
strFilename = "myfile.ext"  ' Put the name of your file here.
                            ' Can be also be piece of the path, like: "folder\myfile"
Set objFileSystem = GetObject("WinNT://" & strServername & "/LanmanServer")

If (IsEmpty(objFileSystem) = False) Then
   For Each Resource In objFileSystem.Resources
      If (Not Resource.User = "") And (Not Right(Resource.User,1) = "$") Then
         If Instr(1, Resource.Path, strFilename ,1) > 0 Then
            WScript.Echo Resource.user & ";" & Resource.Path
         End If 
      End If 
   Next
Else
   WScript.Echo "Error in filesystem , quitting."
   WScript.Quit(2)
End If 

答案2

听起来该文件有一个打开的句柄,阻止对其进行任何修改。您是否尝试过运行 Process Explorer 或其他实用程序来搜索打开的文件句柄并查看哪个进程已将其锁定?

相关内容