批处理 检测 并修改系统屏保时间和密码最大过期时间
2013-11-22 17:56
721 查看
@echo off
secedit /export /cfg c:\security-check-log\temp.txt
find /i "MaximumPasswordAge " c:\security-check-log\temp.txt | find /i "=" > c:\security-check-log\temp2.txt
reg query "HKEY_CURRENT_USER\Control Panel\Desktop" /s | find /i "ScreenSaveTimeOut" >c:\security-check-log\temp3.txt
for /f "tokens=2 delims==" %%a in ('wmic path win32_operatingsystem get LocalDateTime /value') do (
set t=%%a
)
set /p str1=<c:\security-check-log\temp3.txt
set "str1=%str1:~35%"
echo 1.Current ScreenSaveTimeOut is %str1% seconds. > "c:\security-check-log\securitycheck_ %USERNAME% _%t:~0,8%.log"
if %str1% GTR 180 (
echo Check failed! It must be no more than 180 seconds. >> "c:\security-check-log\securitycheck_ %USERNAME% _%t:~0,8%.log"
) else (
echo Check passed! >> "c:\security-check-log\securitycheck_ %USERNAME% _%t:~0,8%.log"
)
set /p str2=<c:\security-check-log\temp2.txt
set "str2=%str2:~21%"
echo 2.Current MaximumPasswordAge is %str2% days. >> "c:\security-check-log\securitycheck_ %USERNAME% _%t:~0,8%.log"
if %str2% GTR 30 (
echo Check failed! It must be no more than 30 days. >> "c:\security-check-log\securitycheck_ %USERNAME% _%t:~0,8%.log"
) else (
echo Check passed! >> "c:\security-check-log\securitycheck_ %USERNAME% _%t:~0,8%.log"
)
del c:\security-check-log\temp.txt
del c:\security-check-log\temp2.txt
del c:\security-check-log\temp3.txt
#上面部分是检测,如果需要修改,在相应的分支中添加如下代码即可
#大于三分钟
if %str1% GTR 180 (
echo It must be no more than 3 minutes.The program is resetting it now!
reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /v ScreenSaveTimeOut /t REG_SZ /d 180 /f
echo The ScreenSaveTimeOut has been resetted.
echo It will be ok after you restart your computer.
) else (
echo The current ScreenSaveTimeOut is ok.
)
#大于30天
if %str2% GTR 30 (
echo It must be no more than 30 days.The program is resetting it now.
pushd "%~dp0" >>sec.inf
echo.[Unicode] >>sec.inf
echo.Unicode=yes >>sec.inf
echo.[Version] >>sec.inf
echo.signature="$CHICAGO$" >>sec.inf
echo.Revision=1 >>sec.inf
echo.[System Access] >>sec.inf
echo.MaximumPasswordAge = 30 >>sec.inf
secedit /configure /db sec.sdb /cfg sec.inf /log sec.log /quiet
del sec.*
echo The MaximumPasswordAge has been resetted.
) else (
echo The current MaximumPasswordAge is ok.
)
secedit /export /cfg c:\security-check-log\temp.txt
find /i "MaximumPasswordAge " c:\security-check-log\temp.txt | find /i "=" > c:\security-check-log\temp2.txt
reg query "HKEY_CURRENT_USER\Control Panel\Desktop" /s | find /i "ScreenSaveTimeOut" >c:\security-check-log\temp3.txt
for /f "tokens=2 delims==" %%a in ('wmic path win32_operatingsystem get LocalDateTime /value') do (
set t=%%a
)
set /p str1=<c:\security-check-log\temp3.txt
set "str1=%str1:~35%"
echo 1.Current ScreenSaveTimeOut is %str1% seconds. > "c:\security-check-log\securitycheck_ %USERNAME% _%t:~0,8%.log"
if %str1% GTR 180 (
echo Check failed! It must be no more than 180 seconds. >> "c:\security-check-log\securitycheck_ %USERNAME% _%t:~0,8%.log"
) else (
echo Check passed! >> "c:\security-check-log\securitycheck_ %USERNAME% _%t:~0,8%.log"
)
set /p str2=<c:\security-check-log\temp2.txt
set "str2=%str2:~21%"
echo 2.Current MaximumPasswordAge is %str2% days. >> "c:\security-check-log\securitycheck_ %USERNAME% _%t:~0,8%.log"
if %str2% GTR 30 (
echo Check failed! It must be no more than 30 days. >> "c:\security-check-log\securitycheck_ %USERNAME% _%t:~0,8%.log"
) else (
echo Check passed! >> "c:\security-check-log\securitycheck_ %USERNAME% _%t:~0,8%.log"
)
del c:\security-check-log\temp.txt
del c:\security-check-log\temp2.txt
del c:\security-check-log\temp3.txt
#上面部分是检测,如果需要修改,在相应的分支中添加如下代码即可
#大于三分钟
if %str1% GTR 180 (
echo It must be no more than 3 minutes.The program is resetting it now!
reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /v ScreenSaveTimeOut /t REG_SZ /d 180 /f
echo The ScreenSaveTimeOut has been resetted.
echo It will be ok after you restart your computer.
) else (
echo The current ScreenSaveTimeOut is ok.
)
#大于30天
if %str2% GTR 30 (
echo It must be no more than 30 days.The program is resetting it now.
pushd "%~dp0" >>sec.inf
echo.[Unicode] >>sec.inf
echo.Unicode=yes >>sec.inf
echo.[Version] >>sec.inf
echo.signature="$CHICAGO$" >>sec.inf
echo.Revision=1 >>sec.inf
echo.[System Access] >>sec.inf
echo.MaximumPasswordAge = 30 >>sec.inf
secedit /configure /db sec.sdb /cfg sec.inf /log sec.log /quiet
del sec.*
echo The MaximumPasswordAge has been resetted.
) else (
echo The current MaximumPasswordAge is ok.
)
相关文章推荐
- 如何查看AIX系统上次密码修改时间
- JWT过期,修改密码,注销登录如何处理
- 修改系统时间并感染exe成为番茄花园的病毒的处理(提供专杀)rising.eve autorun.inf
- 修改Oracle数据库用户的密码过期时间为无限期
- Windows 系统怎样修改主机解析器最大缓存时间 以及否定回答缓存超时时间
- 修改AD域中密码的过期时间
- Linux系统下ACM时间查看修改和文件目录权限处理
- Powershell检测AD账户密码过期时间并邮件通知
- 脚本检测密码过期时间
- 修改Oracle 11g账户密码过期时间
- Windows下如何检测用户修改了系统时间并且把系统时间改回来
- Oracle数据库用户的密码过期时间如何修改为永不过期
- linux 查看、修改用户及密码过期时间
- Powershell检测AD账户密码过期时间并邮件通知 推荐
- 测试需要修改系统时间之后, 引起https证书过期问题
- Powershell检测AD账户密码过期时间并邮件通知
- idea 修改系统时间卡死的处理
- oracle修改用户密码过期时间
- 检测AD密码过期时间并邮件通知
- Android怎样修改系统时间?