使用xp_cmdshell注销Windows登录用户(终端服务器超出最大连接数)

公司日常项目更新使用tfp,服务器一般维护用远程桌面管理,所以经常登录到服务器, 但有时由于某种原因,登录到服务器后,帐号没有及时注销,致使后面无法登录到服务器,

显示错误如

出现这样的问题还真麻烦,跑机房光手续都要两三天才能搞好.还好公司一直保留有sa帐号,

这就好办了,用sql注销一个windows登录用户即可.

首先打开xp_cmdshell
–执行xp_cmdshell要开启xp_cmdshell
exec sp_configure ‘show advanced options’, 1
reconfigure with override
reconfigure
exec sp_configure ‘xp_cmdshell’, 1
reconfigure with override
reconfigure

查看当前windows已登录用户

exec xp_cmdshell ‘query user’

注销id为2的administrator用户
exec xp_cmdshell ‘logoff 2’

–关闭xp_cmdshell
exec sp_configure ‘xp_cmdshell’, 0
reconfigure with override  
reconfigure
exec sp_configure ‘show advanced options’, 0
reconfigure with override
reconfigure

ok,搞定,又可以远程桌面了.

(0)
上一篇 2022年3月21日
下一篇 2022年3月21日

相关推荐