建立bat文件,内容如下:
net use "admin" /user:"administrator"
shutdown -s -f -t 20 -m
net use "admin" /user:"administrator"
shutdown -s -f -t 20 -m
取消关机命令:
shutdown -a -m
如果出现:找不到网络路径的问题,需要查看被关主机的远程桌面是否打开(3389端口),还有就是是否有权限。如果还是不对,使用gpedit.msc来修改本地安全策略。
以上是批量关闭windows机器
批量关闭linux机器方式如下:
1、安装SecureCRT
2、编写bat文件
D:
cd \Program Files\SecureCRT
SecureCRT.exe /script d:\login1.vbs
3、编写script脚本
#$language = "VBScript"
#$interface = "1.0"
Sub main
crt.screen.synchronous = True
crt.session.Connect("192.168.1.64 /L root /Password xxxxxx")
'登录64
crt.screen.send "/root/tg/test_expect" & chr(13)
crt.screen.synchronous = False
End Sub
4、编写test_expect脚本
#!/usr/bin/expect -f
set timeout 5
spawn ssh
expect "password:"
send "downer\r"
expect "]$"
send "exit\r"
interact
spawn ssh
expect "password:"
send "downer\r"
expect "]$"
send "exit\r"
interact
spawn ssh
expect "password:"
send "downer\r"
expect "]$"
send "exit\r"
interact
su - downer
阅读(4654) | 评论(0) | 转发(0) |