无法从 powershell 中删除文件,但可以从 GUI 中删除

Ste*_*ini 4 windows powershell

我正在尝试删除使用 powershell 和 del 生成的文件,但收到此消息

del : Cannot remove item C:\Users\stefano.borini\<redacted>\.tox\py36\Include\fakepq.h: You do not have sufficient access rights to perform this operation.
At line:1 char:1
+ del .\.tox\

+ ~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (fakepq.h:FileInfo) [Remove-Item], IOException
    + FullyQualifiedErrorId : RemoveFileSystemItemUnAuthorizedAccess,Microsoft.PowerShell.Commands.RemoveItemCommand
del : Cannot remove item C:\Users\stefano.borini\<redacted>\.tox\py36\Include\fakesql.h: You do not have sufficient access rights to perform this operation.
Run Code Online (Sandbox Code Playgroud)

但是,我可以右键单击这些项目并从 Windows 资源管理器中删除它们,没有任何问题。为什么?

小智 12

您是否以管理员权限运行 Powershell?

如果是这样,您可以尝试在命令中添加“-force”。

  • 这是正确答案,应勾选。 (2认同)