From d9e1fb3f9bb88f533e9f78cdd119ddd3f29eb66c Mon Sep 17 00:00:00 2001 From: "Michael H.G. Schmidt" Date: Sat, 29 Jul 2023 16:36:24 +0200 Subject: [PATCH] create script for USER access rights in Filesystem #115 --- tools/setuser-fullaccess.cmd | 43 ++++++++++++++++++++++++++++++++++++ tools/setuser-noaccess.cmd | 43 ++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 tools/setuser-fullaccess.cmd create mode 100644 tools/setuser-noaccess.cmd diff --git a/tools/setuser-fullaccess.cmd b/tools/setuser-fullaccess.cmd new file mode 100644 index 0000000..1ab9586 --- /dev/null +++ b/tools/setuser-fullaccess.cmd @@ -0,0 +1,43 @@ +@echo off + +IF %1.==. GOTO USAGE + +if /I %1 == %SystemDrive% goto nosystemdrive +if /I %1 == %SystemDrive%\ goto nosystemdrive + +if NOT EXIST %1 ( + echo ERROR: file or directory not found! + exit /b +) + +echo setting permissions for Users on [ %1 ] to FULLA-ACCESS ... + +if EXIST %1\* ( + + echo *** DIRECTORY mode *** + takeown /F %1 /R /A /D Y 1>nul + icacls %1 /inheritance:r + icacls %1 /grant Administrators:F /t /c /l /q + icacls %1 /grant Users:F /t /c /l /q + +) else ( + + echo *** FILE mode *** + takeown /F %1 /A 1>nul + icacls %1 /inheritance:r + icacls %1 /grant Administrators:F /c /l /q + icacls %1 /grant Users:F /c /l /q + +) +echo. +GOTO END + +:nosystemdrive +echo ERROR: cannot use the SystemDrive! +GOTO END + +:USAGE +echo "usage: %0 " + +:END + diff --git a/tools/setuser-noaccess.cmd b/tools/setuser-noaccess.cmd new file mode 100644 index 0000000..410bd94 --- /dev/null +++ b/tools/setuser-noaccess.cmd @@ -0,0 +1,43 @@ +@echo off + +IF %1.==. GOTO USAGE + +if /I %1 == %SystemDrive% goto nosystemdrive +if /I %1 == %SystemDrive%\ goto nosystemdrive + +if NOT EXIST %1 ( + echo ERROR: file or directory not found! + exit /b +) + +echo removing access rights for Users on [ %1 ] ... + +if EXIST %1\* ( + + echo *** DIRECTORY mode *** + takeown /F %1 /R /A /D Y 1>nul + icacls %1 /inheritance:r + icacls %1 /grant Administrators:F /t /c /l /q + icacls %1 /remove Users /t /c /l /q + +) else ( + + echo *** FILE mode *** + takeown /F %1 /A 1>nul + icacls %1 /inheritance:r + icacls %1 /grant Administrators:F /c /l /q + icacls %1 /remove Users /c /l /q + +) +echo. +GOTO END + +:nosystemdrive +echo ERROR: cannot use the SystemDrive! +GOTO END + +:USAGE +echo "usage: %0 " + +:END +