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

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

显示错误如


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


出现这样的问题还真麻烦,跑机房光手续都要两三天才能搞好.还好公司一直保留有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’


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


注销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,搞定,又可以远程桌面了.

原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/tech/bigdata/234309.html

(0)
上一篇 2022年1月23日 21:23
下一篇 2022年1月23日 21:23

相关推荐

发表回复

登录后才能评论