我想在亚马逊网络服务的EC2服务器上安装git。因此,我使用了Invoke-WebRequest来下载可移植的git exe
Invoke-WebRequest -Uri https://github.com/git-for-windows/git/releases/download/v2.23.0.windows.1/PortableGit-2.23.0-64-bit.7z.exe -UseBasicParsing -OutFile git.exe但是下载卡住了,我终止了会话。现在我想删除git.exe,但由于某些原因,我不被允许这样做。我尝试使用以下命令删除该文件:
Remove-Item .\git.exe但我收到一条错误信息告诉我我不被允许
Remove-Item : Cannot remove item C:\git.exe: Access to the path 'C:\git.exe' is denied.
At line:1 char:1
+ Remove-Item .\git.exe
+ ~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (C:\git.exe:FileInfo) [Remove-Item], UnauthorizedAccessException
+ FullyQualifiedErrorId : RemoveFileSystemItemUnAuthorizedAccess,Microsoft.PowerShell.Commands.RemoveItemCommand发布于 2019-10-24 17:26:57
我刚刚发现Invoke-WebRequest没有正确终止,卡住的进程仍然将文件锁定。重新启动服务器后,我能够删除该文件。感谢您的建议和评论。
https://stackoverflow.com/questions/58522966
复制相似问题