码迷,mamicode.com
首页 > Windows程序 > 详细

配置windows自动修改密码和自动登录

时间:2018-03-20 15:22:35      阅读:325      评论:0      收藏:0      [点我收藏+]

标签:自动化改密

日常运维多台服务器,每季度要修改一次密码,非常麻烦,现做一个VBS脚本,每季度第一天定时运行,则可解决该问题,具体实现脚本如下:
autochg_pwd.vbs

ystr=year(Now)
mstr=Month(Now)
if len(mstr)<2 then mstr="0"&mstr
dstr=day(Now)
if mstr="01" then mstr="!"
if mstr="02" then mstr="!"
if mstr="03" then mstr="!"
if mstr="04" then mstr="@"
if mstr="05" then mstr="@"
if mstr="06" then mstr="@"
if mstr="07" then mstr="#"
if mstr="08" then mstr="#"
if mstr="09" then mstr="#"
if mstr="10" then mstr="$"
if mstr="11" then mstr="$"
if mstr="12" then mstr="$"
pwdstr="testpwd"&ystr&mstr

strComputer="."

Set objUser=GetObject("WinNT://" & strComputer & "/Administrator")

objUser.SetPassword pwdstr

objUser.SetInfo

Dim OperationReGIStry
Set OperationRegistry=WScript.CreateObject("WScript.Shell")
Default=OperationRegistry.RegRead("HKLM\")
OperationRegistry.RegWrite "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultPassword",pwdstr

具体部分脚本需要根据实际情况修改,以上是在windows2012上测试通过(2012修改密码不影响计划任务),实际在windows2003上要注意,由于自动修改密码会导致计划任务异常,不一定适用。

配置windows自动修改密码和自动登录

标签:自动化改密

原文地址:http://blog.51cto.com/lysweb/2088941

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!