@echo off

@rem Title
title Unlock

@rem Adjust window size
mode con:cols=80 lines=30

@rem Define Folder to Unlock

:Folder
cls
echo.
echo Folders in %cd%
echo --------------------------------------------------------------
dir /b /a:d
echo --------------------------------------------------------------
set /p folder_name=FolderName:

@rem Some directions in the code(goto :x)

if not exist "%cd%\%folder_name%" goto Error
if exist "%cd%\%folder_name%" goto Unlock

:Error
@rem Error Message
echo.
echo  %cd%\%folder_name%
echo  Folder Not Found!
@pause 
goto Folder


:Unlock

@rem Unlock Process
cacls "%cd%\%folder_name%" /e /c /g %username%:F

@rem Check if command finished succesfully
if %errorlevel% EQU 0 goto Fixed
if %errorlevel% NEQ 0 goto UnlockError

:UnlockError
@rem Unlock Error
cls
echo.
echo File Not Compatible
@pause
goto Folder

:Fixed
@rem File Unlocked
cls
echo.
echo File Unlocked
@pause

@rem Opens folder through explorer.exe
start explorer.exe "%cd%\%folder_name%" 
exit