管理员帐户在 Windows 7 上拒绝访问文件

发布于 2024-10-09 09:19:36 字数 206 浏览 0 评论 0原文

我想删除我的 Windows 7 机器上由 git 创建的 git 存储库(.git 文件夹)。它说访问被拒绝 .git/refs/header 文件夹。

我以管理员角色打开控制台,发出命令“takeown /F Heads /A /R”,它仍然显示“错误:访问被拒绝。”,我也无法通过 GUI 安全对话框执行此操作。

有什么建议吗?

问候, 绿色的

I want to delete my git repository (.git folder) created by git on my windows 7 box. It says access denied to .git/refs/header folder.

I open a console with Administrator role, issue command "takeown /F heads /A /R", it still says "ERROR: Access is denied.", neither can i do via GUI security dialog.

Any suggestion?

Regards,
Green

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

幸福不弃 2024-10-16 09:19:36

访问被拒绝错误可能意味着该文件正在被另一个进程使用,对于 GIT 存储库,这似乎比文件权限问题更有可能。

(我假设 GIT 就像 SVN,存储库中的每个文件都是由您自己的具有标准权限的帐户创建的。如果情况并非如此,那么我可能是错的。)

  • 第一步,运行 Process Explorer 以管理员身份并按 Ctrl-F 打开一个窗口,您可以在其中键入文件名并查看哪些进程(如果有)打开该文件。

    当我说“以管理员身份运行”时:

    我不仅仅指以管理员身份登录时。 Windows 7 的 UAC 意味着管理员帐户默认情况下不能运行具有完全管理员访问权限的东西。右键单击 procmon.exe 并选择“以管理员身份运行”选项。

    我假设您已经通过以管理员身份运行命令提示符来熟悉这一点。 如果您刚刚更改为管理员帐户,但没有在命令提示符下使用“以管理员身份运行”,则这可能就是 takeown 命令失败的原因。命令提示符应显示“管理员:”如果正确提升了窗口标题,除非 UAC 完全关闭。

  • 如果列出了一个或多个进程,请确认列表中的完整文件路径(以防磁盘上的其他文件具有相似的名称)。

  • 关闭所有打开该文件的进程。如果可以的话,尝试正常关闭它们。作为最后的手段,你可以结束任务。如果它是作为另一个用户/帐户运行的进程,则它可能是您可以停止的服务。

    (确保“查看”->“显示所有用户的进程”被勾选,然后通过 PID 列找到有问题的进程。如果您认为它是一项服务,请将鼠标悬停在它上面,将出现一个工具提示,告诉您名称( s) 正在运行的任何服务。)

  • 如果您找不到任何访问该文件的进程,或者关闭它们仍然会导致访问被拒绝错误,并且您肯定正在尝试从提升的命令提示符中删除,那么您可能需要尝试告诉 Windows 下次重新启动时删除该文件。您可以使用 SysInternals MoveFile 工具来实现此目的。

An access denied error may mean the file is in use by another process and, for a GIT repository, that seems more likely than a file permissions issue.

(I'm assuming GIT is like SVN where every file in the repository is created by your own account with standard permissions. If that's not the case then I may be wrong.)

  • As a first step, run Process Explorer as Administrator and push Ctrl-F to open a window where you can type the filename and see which processes (if any) have that file open.

    When I say "run as Administrator":

    I don't just mean when logged in as Administrator. Windows 7's UAC means Administrator accounts don't run things with full admin access by default. Right-click procmon.exe and choose the "Run as Administrator" option.

    I assume you're already familiar with this from running the command prompt as admin. If you just changed to an admin account, but didn't use "Run as Administrator" on the command prompt, then that could be why the takeown command failed. The command prompt should say "Administrator:" in its window title if it is properly elevated, unless UAC is off entirely.

  • If one or more processes are listed, confirm the full file path in the list (in case some other file on disk has a similar name).

  • Close any processes which have the file open. Try to close them normally if you can. As a last resort you can end-task them. If it's a process running as another user/account, it might be a service which you can stop.

    (Ensure View->Show Processes for All Users is ticked, then find the process in question via the PID column. If you think it's a service, hover the mouse over it and a tooltip will appear telling you the name(s) of any services it is running.)

  • If you cannot find any process accessing the file, or closing them all still results in an access denied error, and you are definitely trying the deletion from an elevated command prompt, then you might want to try telling Windows to delete the file the next time it is rebooted. You can use the SysInternals MoveFile tool for that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文