网上看到的,收藏学习下。

@echo off
cls
echo ##########################################################
echo # #
echo # 设置磁盘权限 #
echo # Tony www.023.com.cn VPS,服务器租用 #
echo # #
echo # 注意事项: #
echo # #
echo # 1 如需使用PHP请先使用“服务器自主管理工具箱”安 #
echo # 装再使用此程序设置权限,若手动安装PHP则需手动 #
echo # 给PHP目录加上USERS的读权限再使用此脚本。 #
echo # #
echo # 2 此脚本只给了网站目录IIS访问帐户的修改权限, #
echo # 如需要使用.net需手动加上IIS_WPG组的权限。 #
echo # #
echo # 3 此脚本只适用于网站服务。 #
echo # #
echo # 4 添加修改权限方法:右键目录叵文件--属性--安全 #
echo # 选择用户,在下方法勾上需要的权限。点击添加-- #
echo # 高级--立即查找,选择用户名确定即可添加用户 #
echo # #
echo ##########################################################
echo.
rem ====================================得到IUSER帐户
net user|find /v "命令成功完成"> %windir%tempisUser1.txt 2>nul
echo.> %windir%tempisUser.txt 2>nul
set webUser=
for /f "skip=4 tokens=1" %%i in (%windir%tempisUser1.txt) do echo %%i>> %windir%tempisUser.txt 2>nul
for /f "skip=4 tokens=2" %%i in (%windir%tempisUser1.txt) do echo %%i>> %windir%tempisUser.txt 2>nul
for /f "skip=4 tokens=3" %%i in (%windir%tempisUser1.txt) do echo %%i>> %windir%tempisUser.txt 2>nul
for /f "skip=1" %%i in (%windir%tempisUser.txt) do call:GetIusr %%i
set /p webUser=输入网站访问帐号(为空则使用默认帐号[%webUser%]):
del /f /q %windir%tempisUser1.txt
del /f /q %windir%tempisUser.txt
goto endGetIusr

:GetIusr
set webUser1=%1
if /i %webUser1:~0,5%==IUSR_ set webUser=%1
goto :eof
:endGetIusr
REM ===============================获取C盘文件列表
set /a No=0
set /a No1=0
set /p=初始化程序... set 退格=
echo y|cacls c: /g administrators:f > nul 2>nul
cacls c: /g system:f /e > nul 2>nul
dir /s /b c: > %windir%tempcacls.txt 2>nul
dir /s /b %windir% > %windir%tempcacls1.txt 2>nul
for /f "tokens=1,2 delims=:" %%a in ('findstr /n ".*" "%windir%tempcacls.txt"') do set /a totalNo=%%a
for /f "tokens=1,2 delims=:" %%a in ('findstr /n ".*" "%windir%tempcacls1.txt"') do set /a totalNo1=%%a+13
set /p=ok < nul
echo.
REM ===============================开始设置C盘权限
set isGoOn=Y
set /p isGoOn=是否设置C盘权限(Y/N)[Y]:
if /i "%isGoOn%"=="N" goto endSetC

set /p=初始化C盘权限... 0/%totalNo%for /f "tokens=* delims=" %%i in (%windir%tempcacls.txt) do call:setAcl "%%i"
set /p=%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%set /p=初始化C盘权限... OK echo.
set /p=设置C盘权限细节... 0/%totalNo1%for /f "tokens=* delims=" %%i in (%windir%tempcacls1.txt) do call:addUsers "%%i"
cacls "%windir%" /t /g Users:r /e /c > nul 2> nul
set /a No1+=1
set /p=%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%set /p=设置C盘权限细节... %No1%/%totalNo1%cacls "C:Program FilesCommon FilesODBC" /g Users:r /e /c > nul 2> nul
set /a No1+=1
set /p=%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%set /p=设置C盘权限细节... %No1%/%totalNo1%cacls "C:Program FilesCommon FilesServices" /g Users:r /e /c > nul 2> nul
set /a No1+=1
set /p=%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%set /p=设置C盘权限细节... %No1%/%totalNo1%cacls "C:Program FilesCommon FilesSystem" /g Users:r /e /c > nul 2> nul
set /a No1+=1
set /p=%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%set /p=设置C盘权限细节... %No1%/%totalNo1%cacls "C:Program Files (x86)Common FilesODBC" /g Users:r /e /c > nul 2> nul
set /a No1+=1
set /p=%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%set /p=设置C盘权限细节... %No1%/%totalNo1%cacls "C:Program Files (x86)Common FilesServices" /g Users:r /e /c > nul 2> nul
set /a No1+=1
set /p=%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退