Version 2 vs 3
Version 2 vs 3
Edits
Edits
- Edit by keithzg, Version 3
- Feb 4 2024 5:59 PM
- Edit by keithzg, Version 2
- Feb 4 2024 5:53 PM
- ·Whoops, I always make that typo
« Previous Change | Next Change » |
Edit Older Version 2... | Edit Older Version 3... |
Content Changes
Content Changes
Windows makes it annoyingly hard to actually wipe files and folders sometimes. It's not even that it's insisting on high permissions, it's that it's finicky and fiddly to apply the right permissions.
The main two commands to use for permissions are `takeown` to take ownership, and `icacls` to change the ACL specifics to allow you to actually delete things. I suppose maybe these are useful for other things but when I'm on Windows I'm generally slashing and burning . . .
```
lang=powershell, name=example recursive deletion
# Use takeown to recursively give ownership to a folder and its contents to the Adminstrators group
takeown /A /R /F ".\some\path"
# Then use icacls to recursively (via /T) grant the admin group full permissions
icacls ".\some\path" /grant Administrators:F /T
# First recursively delete everything //within// a folder, which insanely won't work even with the /R unless a "\*" wildcard declaration is used?! Like you'll literally get "folder is not empty" error which, c'mon guys
Remove-item -Recurse -Force ".\some\path\*"
# Okay now you can actually remove the folder itself, gods Windows is so fucking awkward
Remove-Item ".\some\path"
```
Windows makes it annoyingly hard to actually wipe files and folders sometimes. It's not even that it's insisting on high permissions, it's that it's finicky and fiddly to apply the right permissions.
The main two commands to use for permissions are `takeown` to take ownership, and `icacls` to change the ACL specifics to allow you to actually delete things. I suppose maybe these are useful for other things but when I'm on Windows I'm generally slashing and burning . . .
```
lang=powershell, name=example recursive deletion
# Use takeown to recursively give ownership to a folder and its contents to the Adminstrators group
takeown /A /R /F ".\some\path"
# Then use icacls to recursively (via /T) grant the admin group full permissions
icacls ".\some\path" /grant Administrators:F /T
# If this Remove-Item invocation doesn't work, try appending "\*" to it, sometimes that works (though it doesn't delete the folder itself then) and sometimes it still fails but gives a more accurate error message
Remove-item -Recurse -Force ".\some\path"
```
Windows makes it annoyingly hard to actually wipe files and folders sometimes. It's not even that it's insisting on high permissions, it's that it's finicky and fiddly to apply the right permissions.
The main two commands to use for permissions are `takeown` to take ownership, and `icacls` to change the ACL specifics to allow you to actually delete things. I suppose maybe these are useful for other things but when I'm on Windows I'm generally slashing and burning . . .
```
lang=powershell, name=example recursive deletion
# Use takeown to recursively give ownership to a folder and its contents to the Adminstrators group
takeown /A /R /F ".\some\path"
# Then use icacls to recursively (via /T) grant the admin group full permissions
icacls ".\some\path" /grant Administrators:F /T
# First recursively delete everything //within// a folder, which insanely won't work even with the /R unless a "\*" wildcard declaration is used?! Like you'll literally get "folder is not empty" error whichIf this Remove-Item invocation doesn't work, c'mon guys
Remove-item -Recurse -Force ".\some\path\*"
# Okay now you can actually remove the folder itselftry appending "\*" to it, gods Windows is so fucking awkward
Remove-Item ".\some\path"sometimes that works (though it doesn't delete the folder itself then) and sometimes it still fails but gives a more accurate error message
Remove-item -Recurse -Force ".\some\path"
```