Score:1

Why am I allowed to move, but not delete, a file on Windows Server 2019?

co flag

Today I needed to remove a file, but I couldn't:

[capv@TKG-VC-ANTREA-M]: C:\Users\capv> rm 'C:\Program Files\containerd\containerd-shim-runhcs-v1.exe'
rm : Cannot remove item C:\Program Files\containerd\containerd-shim-runhcs-v1.exe: Access to the path 'C:\Program Files\containerd\containerd-shim-runhcs-v1.exe' is denied.

Oddly, I found a workaround: Just mv it instead, and it worked.

[capv@TKG-VC-ANTREA-M]: C:\Users\capv> mv 'C:\Program Files\containerd\containerd-shim-runhcs-v1.exe' a

After this I was able to accomplish my original goal of untarring the contents of a tarball into this directory..

[capv@TKG-VC-ANTREA-M]: C:\Users\capv> cmd /c tar -zxvf containerd.tar.gz -C "c:/program files/containerd" --strip-components 1
x containerd-shim-runhcs-v1.exe
x containerd-revision.txt
x containerd.exe
x hcsshim-revision.txt
x ctr.exe

Out of curiosity, after moving the file, I tried, but still couldn't delete the moved version of the file:

[capv@TKG-VC-ANTREA-M]: C:\Users\capv> rm a
rm : Cannot remove item C:\Users\capv\a: Access to the path 'C:\Users\capv\a' is denied.
At line:1 char:1

Why would Windows Server allow me to move but not delete this file?

cn flag
FYI, access denied isn't necessarily a permissions issue, although those should be checked. It could be an open handle to the resource.
mp flag
What time of file system do you use? This could have impact as well.
fr flag
If I were to guess the file was kept opened by some process (possibly containerd-shim-runhcs-v1.exe itself) which prevented its deletion. You likely will be able to delete it after process finishes or reboot.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.