If you ever run across a folder with files that you simply cannot delete, try this


This only works for files protected by system or hidden attributes.

It doesn't work if files are owned by TrustedInstaller, which is deliberately done to block casual users from tampering with critical Windows files.
 

My Computer My Computer

At a glance

Windows 7
OS
Windows 7
Portable Disk Genius (freeware)
 

My Computer My Computer

At a glance

Windows 11 Pro
OS
Windows 11 Pro
Computer type
Laptop
Manufacturer/Model
HP EB840G9 i7-1265U 14 16GB/512 PC (7H5E2UP) Serial number: 5CG252048L Product number: 7H5E2UP
Not being a Robocopy user, I didn't see how copying nothing could delete locked files.
The answer lay in the purge aspect of the MIR switch.
Quite a clever solution.(y)
 

My Computer My Computer

At a glance

Windows 11 Pro 24H2i7 Ultra16GBIntel
OS
Windows 11 Pro 24H2
Computer type
Laptop
Manufacturer/Model
LG
CPU
i7 Ultra
Memory
16GB
Graphics Card(s)
Intel
Sound Card
Intel Realtek
Monitor(s) Displays
Laptop 17" & TB4 Dell 27" QHD Ultrasharp w/integral TB4 hub
Screen Resolution
2560x1600
Hard Drives
1TB SSD, 5 external WDs
Mouse
Logitech Master MX 3S
Browser
Vivaldi
Antivirus
Kaspersky Premium Suite
That sounds more like a security hole. But apparently it's supposed to be a "performance optimization".

Does it fail when you throw in "/sec /secfix"?
 

My Computer My Computer

At a glance

Windows 7
OS
Windows 7
..

rmdir /s “\\?\C:\Temp\scratch

will permanently remove the scratch directory+sub-directories+any files within those directories,
which doesn't really matter since they "didn't exist" in the first place.
Well. That would be an odd situation. Never came across such a situation. The first thing that comes to mind is; How can it exist in the first place?
As the GUID Partition Table (GPT) and Master Boot Record (MBR) table is pointing to every file or directory on disk I would check first if the structure doesn't not contain errors. So I would check that first with chkdsk /f /r
 

My Computers My Computers

  • At a glance

    Win 11 Pro 26H2 Build 26300.9550, Zorin OS ProIntel® Core™ i7-12700KF 12th Gen. (S1700)32GB DDR5 5600-36 Vengeance (2x16)PCIe4.0 Asus NVIDIA RTX3060Ti
    OS
    Win 11 Pro 26H2 Build 26300.9550, Zorin OS Pro
    Computer type
    PC/Desktop
    Manufacturer/Model
    Self built
    CPU
    Intel® Core™ i7-12700KF 12th Gen. (S1700)
    Motherboard
    ASUS Prime Z690-A, BIOS v4505 (Z690 Intel Chipset)
    Memory
    32GB DDR5 5600-36 Vengeance (2x16)
    Graphics Card(s)
    PCIe4.0 Asus NVIDIA RTX3060Ti
    Sound Card
    Onboard; Realtek
    Monitor(s) Displays
    34" LG 34UC79G-B Curved 21:9 144Hz
    Screen Resolution
    2560x1080 (No HDR)
    Hard Drives
    250Gb Samsung 870PRO NVMe (Win 11 Pro)
    1Tb Samsung 980PRO NVMe
    1Tb Samsung 970EVO NVMe
    2Tb Samsung 990PRO NVMe with heatsink.
    4Tb WDC WD40EZRZ Blue SATA (Int.)
    4Tb WDC WD40EZRZ Blue SATA (Int.)
    3Tb WDC WD30EFRZ Red SATA (Int.)
    256Gb Samsung 840PRO SSD (RHEL 9,5)
    256Gb Samsung 850PRO SSD (Zorin OS Pro 18)
    PSU
    Coolermaster 850W V2 Gold with internal 12cm exaust fan
    Case
    Be-Quiet Pure Base 600.
    Cooling
    3x Be-Quiet! 12/14cm "Silent Wings 4" casefans, 1x Arctic Freezer i35 CPU towerblock with fan.
    Keyboard
    Steelseries APEX 7 keyboard.
    Mouse
    Logitech G-502 Hero
    Internet Speed
    1Gb
    Browser
    Brave
    Antivirus
    F-Secure
    Other Info
    No Noise system.
    256Gb Kingston Travler USB 3.0 drive.
    64Gb Sandisk USB 3.2 drive. (Ventoy)
    8Gb Philips USB 3.0 drive. (Win. Inst.)
    8Gb Philips USB 3.0 drive. (Rescue disk)
    2Tb WD USB 3.0 Passport drive.
    USB Ext. 500Gb WD SATA drive.
    External USB 3.0 C.A. CD/DVD* burner.
  • At a glance

    Windows 11 Pro 26H2Intel® Core™ i7-6700K 6th Gen. (S1151)32Gb DDR4 2400 Corsair Vengeance (4x8)ASUS GeForce GTX1080
    Operating System
    Windows 11 Pro 26H2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Selfbuild
    CPU
    Intel® Core™ i7-6700K 6th Gen. (S1151)
    Motherboard
    ASUS Maximus VIII Ranger (Intel Chipset Z170)
    Memory
    32Gb DDR4 2400 Corsair Vengeance (4x8)
    Graphics card(s)
    ASUS GeForce GTX1080
    Sound Card
    Onboard; Realtek
    Monitor(s) Displays
    LG IPS277L 27" WideLED, IPS
    Screen Resolution
    1920x1080
    Hard Drives
    Samsung 850 Pro SSD
    PSU
    Zalman ZM600-HP with internal exhaust fan. Heatpipes & Modular cables.
    Case
    Cooler Master Aero
    Cooling
    Scythe Mugen 4 dual fan towerblock.
    Keyboard
    Red Dragon
    Mouse
    Red Dragon
    Internet Speed
    1Gb
    Browser
    Brave
    Antivirus
    F-Secure
Robocopy gets around all of that because it has special permissions, so it does not matter who owns the files.
I'm surprised by this. Robocopy has a /b option that will use backup and restore privileges to enable copying and deleting of files where you don't have permissions, but you don't seem to be using that option.

A different problem is very long (more that 260 characters) path names. Windows file explorer can't deal with this. Cmd can, putting \\?\ in front of a file path converts it to a Win32 device name which can enable access to very long path names. (this is explained here: Long filenames - Windows CMD).

However, using robocopy as you suggest also deals with this problem. Robocopy always uses the functions that support very long path names unless specifically turned off,
 

My Computers My Computers

  • At a glance

    Windows 11 25H2 Pro Build 26200i3-1215U8GB
    OS
    Windows 11 25H2 Pro Build 26200
    Computer type
    PC/Desktop
    Manufacturer/Model
    MSI PRO ADL-U Cubi 5 (MS-B0A8)
    CPU
    i3-1215U
    Memory
    8GB
    Monitor(s) Displays
    Sony 43" 4k TV
    Screen Resolution
    3840x2160
    Hard Drives
    250GB NVMe M.2 PCIe Gen 3 SSD
    PSU
    External 65W
    Case
    Mini PC
    Browser
    FireFox
    Antivirus
    MS
  • At a glance

    Windows 11 Pro 25H2Intel i3-910016GB DDR4
    Operating System
    Windows 11 Pro 25H2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Dell Optiplex 3070 SFF
    CPU
    Intel i3-9100
    Memory
    16GB DDR4
    Monitor(s) Displays
    Dell S2721
    Screen Resolution
    3840 x 2160
    Hard Drives
    Samsung 500GB nvMe
    Case
    Dell small form factor
    Keyboard
    Cherry mechanical (Blue)
    Mouse
    Microsoft
    Antivirus
    MS Defender
I'm surprised by this. Robocopy has a /b option that will use backup and restore privileges to enable copying and deleting of files where you don't have permissions, but you don't seem to be using that option.

A different problem is very long (more that 260 characters) path names. Windows file explorer can't deal with this. Cmd can, putting \\?\ in front of a file path converts it to a Win32 device name which can enable access to very long path names. (this is explained here: Long filenames - Windows CMD).

However, using robocopy as you suggest also deals with this problem. Robocopy always uses the functions that support very long path names unless specifically turned off,
On this subject of long paths. Came across an issue by RoboCopy-ing my Users folder. In the log files I saw errors and at the destination I came across a flaw with RoboCopy. A certain Windows directory was nesting itself until it gave up. 15 directory's deep all with the same name. It was a not accessible hidden directory called "Application Data". Other directory's had this issue also like "History" and "Temporary Internet Files" Those not accessible directory's weren't meant to be backup up. In order to exclude those directory's I had to use the following switches for RoboCopy: /XA:SH /XJD and /XD
 

My Computers My Computers

  • At a glance

    Win 11 Pro 26H2 Build 26300.9550, Zorin OS ProIntel® Core™ i7-12700KF 12th Gen. (S1700)32GB DDR5 5600-36 Vengeance (2x16)PCIe4.0 Asus NVIDIA RTX3060Ti
    OS
    Win 11 Pro 26H2 Build 26300.9550, Zorin OS Pro
    Computer type
    PC/Desktop
    Manufacturer/Model
    Self built
    CPU
    Intel® Core™ i7-12700KF 12th Gen. (S1700)
    Motherboard
    ASUS Prime Z690-A, BIOS v4505 (Z690 Intel Chipset)
    Memory
    32GB DDR5 5600-36 Vengeance (2x16)
    Graphics Card(s)
    PCIe4.0 Asus NVIDIA RTX3060Ti
    Sound Card
    Onboard; Realtek
    Monitor(s) Displays
    34" LG 34UC79G-B Curved 21:9 144Hz
    Screen Resolution
    2560x1080 (No HDR)
    Hard Drives
    250Gb Samsung 870PRO NVMe (Win 11 Pro)
    1Tb Samsung 980PRO NVMe
    1Tb Samsung 970EVO NVMe
    2Tb Samsung 990PRO NVMe with heatsink.
    4Tb WDC WD40EZRZ Blue SATA (Int.)
    4Tb WDC WD40EZRZ Blue SATA (Int.)
    3Tb WDC WD30EFRZ Red SATA (Int.)
    256Gb Samsung 840PRO SSD (RHEL 9,5)
    256Gb Samsung 850PRO SSD (Zorin OS Pro 18)
    PSU
    Coolermaster 850W V2 Gold with internal 12cm exaust fan
    Case
    Be-Quiet Pure Base 600.
    Cooling
    3x Be-Quiet! 12/14cm "Silent Wings 4" casefans, 1x Arctic Freezer i35 CPU towerblock with fan.
    Keyboard
    Steelseries APEX 7 keyboard.
    Mouse
    Logitech G-502 Hero
    Internet Speed
    1Gb
    Browser
    Brave
    Antivirus
    F-Secure
    Other Info
    No Noise system.
    256Gb Kingston Travler USB 3.0 drive.
    64Gb Sandisk USB 3.2 drive. (Ventoy)
    8Gb Philips USB 3.0 drive. (Win. Inst.)
    8Gb Philips USB 3.0 drive. (Rescue disk)
    2Tb WD USB 3.0 Passport drive.
    USB Ext. 500Gb WD SATA drive.
    External USB 3.0 C.A. CD/DVD* burner.
  • At a glance

    Windows 11 Pro 26H2Intel® Core™ i7-6700K 6th Gen. (S1151)32Gb DDR4 2400 Corsair Vengeance (4x8)ASUS GeForce GTX1080
    Operating System
    Windows 11 Pro 26H2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Selfbuild
    CPU
    Intel® Core™ i7-6700K 6th Gen. (S1151)
    Motherboard
    ASUS Maximus VIII Ranger (Intel Chipset Z170)
    Memory
    32Gb DDR4 2400 Corsair Vengeance (4x8)
    Graphics card(s)
    ASUS GeForce GTX1080
    Sound Card
    Onboard; Realtek
    Monitor(s) Displays
    LG IPS277L 27" WideLED, IPS
    Screen Resolution
    1920x1080
    Hard Drives
    Samsung 850 Pro SSD
    PSU
    Zalman ZM600-HP with internal exhaust fan. Heatpipes & Modular cables.
    Case
    Cooler Master Aero
    Cooling
    Scythe Mugen 4 dual fan towerblock.
    Keyboard
    Red Dragon
    Mouse
    Red Dragon
    Internet Speed
    1Gb
    Browser
    Brave
    Antivirus
    F-Secure
Back
Top Bottom