Windows/Delete Unowned Folder: Difference between revisions
< Windows
(Created page with " takeown /f "C:\Path\To\Folder" /r /d y icacls "C:\Path\To\Folder" /grant Administrators:F /t rmdir /s /q "C:\Path\To\Folder"") |
No edit summary |
||
| (3 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
Run from a user in Administrators group, and from a command line window elevated to Administrator permission | |||
# Take ownership as self (CMD or Powershell) | |||
takeown /f "C:\Path\To\Folder" /r /d y | takeown /f "C:\Path\To\Folder" /r /d y | ||
# OR | |||
# Take owenership as Administrator group (CMD or Powershell) | |||
takeown /A /f "C:\Path\To\Folder" /r /d y | |||
# Give full permission to Administrator group | |||
icacls "C:\Path\To\Folder" /grant Administrators:F /t | icacls "C:\Path\To\Folder" /grant Administrators:F /t | ||
# CMD: remove the directory | |||
rmdir /s /q "C:\Path\To\Folder" | rmdir /s /q "C:\Path\To\Folder" | ||
# OR | |||
# Powershell: remove the directory | |||
Remove-Item -Path "C:\Path\To\Folder" -Recurse -Force | |||
# alias rmdir | |||
rmdir -Path "C:\Path\To\Folder" -Recurse -Force | |||
Note: only reason "rmdir" won't work correctly in powershell, is Powershell aliases to Remove-Item | |||
Latest revision as of 08:22, 5 January 2026
Run from a user in Administrators group, and from a command line window elevated to Administrator permission
# Take ownership as self (CMD or Powershell) takeown /f "C:\Path\To\Folder" /r /d y # OR # Take owenership as Administrator group (CMD or Powershell) takeown /A /f "C:\Path\To\Folder" /r /d y
# Give full permission to Administrator group icacls "C:\Path\To\Folder" /grant Administrators:F /t
# CMD: remove the directory rmdir /s /q "C:\Path\To\Folder" # OR # Powershell: remove the directory Remove-Item -Path "C:\Path\To\Folder" -Recurse -Force # alias rmdir rmdir -Path "C:\Path\To\Folder" -Recurse -Force
Note: only reason "rmdir" won't work correctly in powershell, is Powershell aliases to Remove-Item