set ListFlodercount=100
set ListGroupcount=100
for /f "delims=" %%a in ('dir *. /b') do (set /a ListFlodercount+=1&&call set ListFloder%%ListFlodercount%%=%CD%\%%a&&call SET MaxFloderNumber=%%ListFlodercount%%)
for /f "skip=1 delims= " %%a in ('wmic group list brief') do (set /a ListGroupcount+=1&&call set ListGroup%%ListGroupcount%%=%%a&&call SET MaxGroupNumber=%%ListGroupcount%%)
echo.F Full control
echo.M Modify
echo.X read & eXecute
echo.L List folder contents
echo.R Read
echo.W Write
set access=
set /p access=Type F or M or X or L or R or W:
xcacls.vbs "ListFloder%%ListFlodercount%%" /g "ListGroup%%ListGroupcount%%":%access%
@echo off
for /d %%a in (*) do (
for /f "skip=4 tokens=* delims=*" %%i in ('net localgroup') do (
call cscript xcacls.vbs %%xxx%%%%xccess%%
echo Folder:%%a
echo Group:%%i
echo.
echo.F Full control
echo.M Modify
echo.X read ^& eXecute
echo.L List folder contents
echo.R Read
echo.W Write
set xccess=
set /p xccess=Type F or M or X or L or R or W:
set xxx="%%a" /e /g "%%i":
)
)
A群組,B群組,C群組
第一資料夾,R,W,F
第二資料夾,R,R,F
第三資料夾,W,W,F
第四資料夾,F,F,F
call cscript xcacls.vbs "%%f" /g "%COMPUTERNAME%%%g":%%s
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
dir /b *. > FloderList.txt
for /f " tokens=1 delims=," %%f in (FloderList.txt) do (
for /f " tokens=1 delims=," %%g in (GroupList.txt) do (
echo %%f-%%g
)
)
)
for /f "skip=1 tokens=2 delims=," %%s in (SecureList.txt) do (echo %%s)
)
rem call cscript xcacls.vbs "%%f" /g "%COMPUTERNAME%%%g":%%s
E:\zz>zz.bat
第一資料夾-A群組
第三資料夾-A群組
第二資料夾-A群組
第四資料夾-A群組
R
R
W
F
A群組,B群組,C群組
第一資料夾,R,W,F
第二資料夾,R,R,F
第三資料夾,W,W,F
第四資料夾,F,F,F
A群組,B群組,C群組
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
for /f " tokens=1-10 delims=," %%u in (GroupList.txt) do (
for /f "skip=1 tokens=1-15 delims=," %%a in (SecureList.txt) do (
echo========================================================
echo 資料夾 群組 安全性
echo %%a %%u %%b
echo %%a %%v %%c
echo %%a %%w %%d
rem call cscript xcacls.vbs "資料夾" /g "群組":安全性 /e
rem call cscript xcacls.vbs "%%a" /g "%%u":%%b /e
rem call cscript xcacls.vbs "%%a" /g "%%v":%%c /e
rem call cscript xcacls.vbs "%%a" /g "%%w":%%d /e
)
)
E:\zz>zz
=======================================================
資料夾 群組 安全性
第一資料夾 A群組 R
第一資料夾 B群組 W
第一資料夾 C群組 F
=======================================================
資料夾 群組 安全性
第二資料夾 A群組 R
第二資料夾 B群組 R
第二資料夾 C群組 F
=======================================================
資料夾 群組 安全性
第三資料夾 A群組 W
第三資料夾 B群組 W
第三資料夾 C群組 F
=======================================================
資料夾 群組 安全性
第四資料夾 A群組 F
第四資料夾 B群組 F
第四資料夾 C群組 F
E:\zz>
A群組,B群組,C群組
第一資料夾,R,W,F
第二資料夾,R,R,F
第三資料夾,W,W,F
第四資料夾,F,F,F
A群組,B群組,C群組
for /f "tokens=1-25 delims=," %%B in (SecureList.txt) do (
for /f "skip=1 tokens=1-26 delims=," %%a in (SecureList.txt) do (
cacls "%%~a" /t /e /p %%B%%b %%C%%c %%D%%d %%E%%e %%F%%f %%G%%g %%H%%h %%I%%i %%J%%j %%K%%k %%L%%l %%M%%m %%N%%n %%O%%o %%P%%p %%Q%%q %%R%%r %%S%%s %%T%%t %%U%%u %%V%%v %%W%%w %%X%%x %%Y%%y %%Z%%z
)
exit/b
)
A群組:,"B 群 組:",C群組: 第一資料夾,R,C,F 第二資料夾,R,R,F 第三資料夾,C,C,F 第四資料夾,F,F,F
@echo off & SETLOCAL ENABLEDELAYEDEXPANSION
:flag
for /f "%flag% delims=" %%a in (SecureList.txt) do (
set str=%%a&&set str=!str:,= !&set num=1
if "%flag%"=="" call :lp !str!&set flag=skip=1&goto flag
echo========================================================
echo 資料夾 群組 安全性
call :lp1 !str!
)
pause&exit
:lp1
set name=%1&shift
:lp
if not "%flag%"=="" (
echo %name% !Group%num%! %1
rem call cscript xcacls.vbs "%name%" /g "!Group%num%!":%1 /e
) else set Group%num%=%1
shift
if not "%1"=="" set/a num+=1&goto lp
Originally posted by mkd at 2008-5-28 02:15 PM: [code] for /f "tokens=1-25 delims=," %%B in (SecureList.txt) do ( for /f "skip=1 tokens=1-26 delims=," %%a in (SecureList.txt) do ( cacls "%%~a" /t /e /p %%B%%b ...感謝 隻所以不用CACAS.exe 因為它不支援 列表的權限.. 不過我也學到了 原來只要這麼短就可以達到相同的需求= =" 看來我要學的路還很遠^^
Originally posted by tao0610 at 2008-5-28 06:09 PM: 按你那个改了一下 [code] @echo off & SETLOCAL ENABLEDELAYEDEXPANSION :flag for /f "%flag% delims=" %%a in (SecureList.txt) do ( set str=%%a&&set str=!str:,= !& ...只能說強!!功能達到 請問能大概解釋一下 這樣子寫法 好深奧 看不懂= = 謝謝您 我再努力領悟中
全權控制
修改
讀取與執行
清單資料夾內容
讀取
寫入
特殊權限
/G user:GUI Grant security permissions similar to Windows GUI
standard (non-advanced) choices.
/G user:Perm;Spec Grant specified user access rights.
(/G adds to existing rights for user)
User: If User has spaces in it, enclose it in quotes.
If User contains #machine#, it will replace
#machine# with the actual machine name if it is a
non-domain controller, and replace it with the
actual domain name if it is a domain controller.
New to 3.0: User can be a string representing
the actual SID, but MUST be lead by SID#
Example: SID#S-1-5-21-2127521184-160...
(SID string shown has been shortened)
(If any user has SID# then globally all
matches must match the SID (not name)
so if your intention is to apply changes
to all accounts that match Domain\User
then do not specify SID# as one of the
users.)
GUI: Is for standard rights and can be:
Permissions...
F Full control
M Modify
X read and eXecute
L List folder contents
R Read
W Write
Note: If a ; is present, this will be considered
a Perm;Spec parameter pair.
Perm: Is for "Files Only" and can be:
Permissions...
F Full control
M Modify
X read and eXecute
R Read
W Write
Advanced...
D Take Ownership
C Change Permissions
B Read Permissions
A Delete
9 Write Attributes
8 Read Attributes
7 Delete Subfolders and Files
6 Traverse Folder / Execute File
5 Write Extended Attributes
4 Read Extended Attributes
3 Create Folders / Append Data
2 Create Files / Write Data
1 List Folder / Read Data
Spec is for "Folder and Subfolders only" and has the
same choices as Perm.