Use when the user asks to delete an exact Windows file or folder and normal removal is blocked by file locks, driver locks, redirected Desktop paths, or directory handles; includes real-path resolution, lock diagnosis, and reboot-time deletion fallbacks.
설치
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
Use when the user asks to delete an exact Windows file or folder and normal removal is blocked by file locks, driver locks, redirected Desktop paths, or directory handles; includes real-path resolution, lock diagnosis, and reboot-time deletion fallbacks.
Windows Locked Path Delete
Core Workflow
Resolve the exact target path before destructive action.
If the target is on the Desktop, use [Environment]::GetFolderPath('Desktop') instead of guessing the Desktop location.
Attempt one ordinary removal with Remove-Item -LiteralPath <path> -Recurse -Force.
If it fails, capture the exact error and inspect whether files remain or only the directory handle is locked.
Check likely lock owners, including foreground processes and system drivers when security software is involved.
Use the smallest suitable fallback:
close the owning process when clearly safe,
schedule deletion on reboot with a native path,
or append to PendingFileRenameOperations without clobbering existing entries.
Tell the user whether deletion happened immediately or is queued for the next reboot.
Decision Rules
Destructive actions must operate on resolved absolute paths.
Do not touch sibling directories or inferred targets.
Do not keep retrying the same delete command after a repeated lock error.
Treat an empty but undeletable directory as a directory-handle lock.
Preserve existing pending rename operations if editing the registry fallback.
Verification
The resolved path matches the user's requested target.
Immediate deletion success or failure is known.
Any lock diagnosis is based on real processes, services, drivers, or filesystem state.
Reboot-time deletion is actually scheduled when claimed.