Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- if exist "%temp%\fixpermissions.tmp" goto skip
- if "%~nx1"=="" echo Drag and drop a file/folder.&echo.&pause&exit
- if NOT "%~nx2"=="" echo Error! Only one file/folder can be processed at once.&echo.&pause&exit
- for /f "tokens=1,2 delims=d" %%A in ("-%~a1") do if "%%B" neq "" (set isfolder=1) else if "%%A" neq "-" (set isfile=1)
- if exist "%temp%\fixpermissions.isfolder.tmp" del /Q "%temp%\fixpermissions.isfolder.tmp"
- if exist "%temp%\fixpermissions.isfile.tmp" del /Q "%temp%\fixpermissions.isfile.tmp"
- if "%isfolder%"=="1" type NUL>"%temp%\fixpermissions.isfolder.tmp"
- if "%isfile%"=="1" type NUL>"%temp%\fixpermissions.isfile.tmp"
- echo.%~dpnx1>"%temp%\fixpermissions.tmp"
- :skip
- set /P target=<"%temp%\fixpermissions.tmp"
- (cd /d "%~dp0")&&(NET FILE||(powershell -noprofile start-process -FilePath '%0' -verb runas)&&(exit /B)) >NUL 2>&1
- if exist "%temp%\fixpermissions.tmp" del /Q "%temp%\fixpermissions.tmp"
- net file >nul 2>&1
- if NOT %ERRORLEVEL% EQU 0 exit
- if exist "%temp%\fixpermissions.isfolder.tmp" takeown /R /F "%target%" /D Y
- if exist "%temp%\fixpermissions.isfile.tmp" takeown /F "%target%"
- if exist "%temp%\fixpermissions.isfolder.tmp" del /Q "%temp%\fixpermissions.isfolder.tmp"
- if exist "%temp%\fixpermissions.isfile.tmp" del /Q "%temp%\fixpermissions.isfile.tmp"
- icacls "%target%" /reset /T /C
- echo.
- pause
- exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement