Skip to content

Instantly share code, notes, and snippets.

@fengye
Last active July 7, 2019 04:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fengye/c2726b5219a83e538047b752baa1b707 to your computer and use it in GitHub Desktop.
Save fengye/c2726b5219a83e538047b752baa1b707 to your computer and use it in GitHub Desktop.
Take ownership and assign permission then remove all the files recursively in one folder
@echo off
setlocal
:PROMPT
@echo DELETING %1 !!!
SET /P AREYOUSURE=Are you sure (Y/[N])?
IF /I "%AREYOUSURE%" NEQ "Y" GOTO END
takeown /f %1 /r /d y
icacls %1 /grant Everyone:(OI)(CI)F /T
icacls %1 /grant %username%:F /T
rmdir /Q /S %1
:END
endlocal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment