Windows DEL command behavior wrt junction points

pn flag

In my installer script I want to delete known files from known locations on the local PC using the DEL command. The command should purge the file from a certain folder and all subfolders below that. I therefore use:

cd /d "C:\MyFolder"
del /f /s /q

However, if a junction is mapped somewhere below "C:\MyFolder" (say, at "C:\MyFolder\Junction", pointing to another folder on the same drive), DEL doesn't seem to traverse into it at all. So all "" files under there will not be deleted. If DEL also cannot find the file anywhere else under the root folder, it'll also happily report "Could Not Find C:\MyFolder\".

There doesn't seem to be any switches that control this behavior, nor do command extensions help -- is this a known limitation of DEL?

Are there any workarounds using either commands or standard apps installed by default on fresh contemporary Windows machines, or should I write my own DEL-like executable for this / perform the same action using a script in my installer?

cn flag

If the junction point is hosted on the network the problem is most probably the installation script need to be runned as a admin.

Running it as an admin make it use local credential, and most junction point point to a network share usually, thus the DEL command lack the credential to navigate the junction point.

Carl Colijn avatar
pn flag
Thanks for the insight! But this is all on my local machine, no network in sight :) I'll update my post to include this.
yagmoth555 avatar
cn flag
@CarlColijn Thansk for edit. If you run such command; Get-ChildItem -Path "c:\MyFolder" -File -Include -Recurse | Remove-Item -Force -Verbose does it work ? if yes I would tend to think like you a del limitation then
Carl Colijn avatar
pn flag
Yep; that powershell snippet does work, even when ran from outside the junction. So probably a built-in DEL limitation indeed. Problem is I don't think I can convince the guy maintaining the script to start using Powershell :) Luckily this problem is almost only theoretical though (so far we know it only from my dev machine and not from customers).

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.