Board logo

标题: [其他] 自动批处理修改域中每台电脑的本地管理员密码 [打印本页]

作者: gifma    时间: 2021-12-15 11:12     标题: 自动批处理修改域中每台电脑的本地管理员密码

@echo on
if exist \\aaaks.com\SysVol\aaaks.com\userpasswd\%computername:~0,40%.txt goto _end
echo %date%  %time% >\\aaaks.com\SysVol\aaaks.com\userpasswd\%computername:~0,40%.txt
echo %computername:~0,40% >>\\aaaks.com\SysVol\aaaks.com\userpasswd\%computername:~0,40%.txt


for /f "tokens=1,2* delims=:" %%a in ('ipconfig ^|findstr "IP Address"') do set ip=%%b
echo %ip%>>\\aaaks.com\SysVol\aaaks.com\userpasswd\%computername:~0,40%.txt
echo %ip:~9,40%>>\\aaaks.com\SysVol\aaaks.com\userpasswd\%computername:~0,40%.txt

echo @aaa20210705%ip:~9,40%>>\\aaaks.com\SysVol\aaaks.com\userpasswd\%computername:~0,40%.txt
net user administrator @aaa20210705%ip:~9,40%>>\\aaaks.com\SysVol\aaaks.com\userpasswd\%computername:~0,40%.txt

echo %date%  %time% %computername:~0,40% %ip% @aaa20210705%ip:~9,40%>>\\aaaks.com\SysVol\aaaks.com\userpasswd\change.txt
rem echo %computername:~0,40%>>\\aaaks.com\SysVol\aaaks.com\userpasswd\change.txt
rem echo %ip%>>\\aaaks.com\SysVol\aaaks.com\userpasswd\change.txt
rem echo @aaa20210705%ip:~9,40%>>\\aaaks.com\SysVol\aaaks.com\userpasswd\change.txt
:_end

已知以上代码为自动批处理修改域中每台电脑的本地管理员为不同的密码
请大神分段分析下以上代码,谢谢。
作者: holley    时间: 2021-12-17 10:44

1段:如果服务器上不存在此计算机名的文本则填入一行日期时间,一行计算机名
2段:继续写入一行IP地址,一行对IP截取后的一个数值
3段:再次继续将指定的密码写入,修改管理员密码为 @aaa20210705加IP进行截取后的数值
4段:将前3段的操作写入服务器上的change文本。
最后几行注释掉了




欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2