Windows systems sometimes refuse to delete folders even when the user has full administrator rights. This commonly happens with copied or migrated Users folders stored on secondary drives. The issue becomes more complex when files like NTUSER.DAT remain locked by the operating system, or when deeply nested folders exceed the Windows MAX_PATH limitation.
This article explains the technical reasons behind the issue and provides multiple advanced methods to safely remove undeletable folders using Command Prompt, PowerShell, Safe Mode, registry hive unloading, and long-path deletion techniques.
When attempting to delete a copied Windows profile folder such as:
D:\Users
users may encounter errors like:
The primary causes are:
NTUSER.DAT)
HKEY_USERS
NTUSER.DAT is a Windows user registry hive file stored inside each user profile.
Example:
D:\Users\Administrator\NTUSER.DAT
This file contains:
When Windows loads a user profile, this file is mounted into the registry under:
HKEY_USERS
As long as the hive remains mounted, Windows locks the file and prevents deletion.
Typical deletion failures include:
The process cannot access the file because it is being used by another process.
You require permission from Administrator.
The directory name is too long.
Open Command Prompt as Administrator and run:
takeown /f "D:\Users" /r /d y
Grant full permissions:
icacls "D:\Users" /grant administrators:F /t
Remove hidden/system attributes:
attrib -h -r -s "D:\Users" /s /d
These commands ensure the administrator account has complete access to all files and subfolders.
Modern Windows versions still struggle with extremely deep folder structures.
Example problematic path:
D:\Users\ayush\Downloads\New folder\New folder (2)\New folder (4)\...
To bypass Windows MAX_PATH limitations, use the special long-path syntax:
\\?\
Delete command:
rd /s /q "\\?\D:\Users"
This instructs Windows to bypass normal path parsing and process the full absolute path directly.
Many users terminate Explorer to release file locks:
taskkill /f /im explorer.exe
However, explorer.exe controls:
In Remote Desktop (RDP) sessions, killing Explorer removes the entire graphical shell, resulting in a black or blank screen.
To restore it:
start explorer.exe
or from Task Manager:
File → Run new task → explorer.exe
Check loaded registry hives:
reg query HKU
You may see entries like:
HKEY_USERS\S-1-5-21-xxxxxxxxxx
Unload non-system hives:
reg unload "HKU\S-1-5-21-XXXXXXXX-1001"
Do NOT unload:
.DEFAULT
S-1-5-18
S-1-5-19
S-1-5-20
After unloading:
del /f /q /a "\\?\D:\Users\Administrator\NTUSER*"
Then remove the directory:
rd /s /q "\\?\D:\Users"
If files remain locked, Safe Mode is the best solution because Windows loads minimal services and does not mount inactive user profile hives.
Run:
msconfig
Go to:
Restart the computer.
In Safe Mode, run:
rd /s /q "\\?\D:\Users"
This method usually succeeds instantly.
PowerShell provides an alternative deletion method:
Remove-Item "\\?\D:\Users" -Recurse -Force
Delete only the Administrator profile:
Remove-Item "\\?\D:\Users\Administrator" -Recurse -Force
A lesser-known but powerful trick uses robocopy to mirror an empty directory over the problematic folder.
Create empty folder:
mkdir C:\Empty
Mirror empty structure:
robocopy /MIR C:\Empty "D:\Users"
Then delete:
rd /s /q "\\?\D:\Users"
This clears many nested files and invalid paths automatically.
Windows registry hives also create transaction logs:
NTUSER.DAT.LOG1
NTUSER.DAT.LOG2
*.regtrans-ms
*.TM.blf
These files support registry recovery and consistency.
Safe Mode usually unlocks them automatically.
Before deleting any copied Windows profile folder:
Deleting stubborn Windows profile folders requires understanding how Windows manages registry hives, file locks, and path limitations.
The most effective combination is:
\\?\)
Using these techniques allows administrators to safely remove undeletable folders such as copied Users directories from secondary drives without reinstalling Windows or using third-party utilities.