Take precautions so set-perms.bat and unset-perms.bat are not ran as TrustedInstaller

This commit is contained in:
Fierelier 2022-06-28 08:55:02 +02:00
parent 2e32dba026
commit 8d923b8d89
3 changed files with 13 additions and 1 deletions

View File

@ -1,6 +1,11 @@
@echo off
setlocal
cd /d "%~dp0"
if "%isTrustedInstaller%" == "1" (
echo Do not run this script as TrustedInstaller, run it as Administrator.
pause
goto exit
)
echo Setting permissions...
icacls "%cd%" /setowner Administrators /T /C /L /Q >nul
icacls "%cd%" /reset /T /C /L /Q >nul
@ -8,4 +13,5 @@ icacls "%cd%" /inheritance:e /T /C /L /Q >nul
icacls "%cd%" /inheritance:r /C /L /Q >nul
icacls "%cd%" /setowner Administrators /T /C /L /Q >nul
icacls "%cd%" /grant Users:(OI)(CI)RX /grant Administrators:(OI)(CI)F /grant "NT SERVICE\TrustedInstaller":(OI)(CI)F /grant SYSTEM:(OI)(CI)F /T /C /L /Q >nul
pause
pause
:exit

View File

@ -18,6 +18,7 @@ if not "%~1" == "-ti-run" (
)
endlocal & set "pyexe=%pyexe%"
set "isTrustedInstaller=1"
set "pyexe=%pyexe:"=%"
set "path=%cd%\path;%path%"
set "cmd=%*"

View File

@ -1,6 +1,11 @@
@echo off
setlocal
cd /d "%~dp0"
if "%isTrustedInstaller%" == "1" (
echo Do not run this script as TrustedInstaller, run it as Administrator.
pause
goto exit
)
echo Setting permissions...
icacls "%cd%" /reset /T /C /L /Q >nul
pause