Use xp_cmdshell to log out of a Windows user (the maximum number of connections is exceeded on the terminal server)

Source: Internet
Author: User

TFP is used for daily project updates in the company, and Remote Desktop Management is generally used for server maintenance. Therefore, you often log on to the server. However, for some reason, after logging on to the server, the account is not logged out in time, as a result, you cannot log on to the server,

Display Error as shown in

It is really troublesome to have such a problem. It takes two or three days to complete the data center optical procedures. Fortunately, the company has always kept its Sa account,

This is easy to do. Simply use SQL to log out of a Windows login user.

First open xp_cmdshell
-- Run XP_CMDSHELL to enable xp_cmdshell.
EXEC sp_configure 'show advanced options', 1
RECONFIGURE WITH OVERRIDE
RECONFIGURE
EXEC sp_configure 'xp _ Your shell', 1
RECONFIGURE WITH OVERRIDE
RECONFIGURE

View logged-on users in Windows

EXEC xp_query shell 'query user'

Log out of the Administrator user whose Id is 2
EXEC xp_mongoshell 'logoff 2'

-- Disable xp_cmdshell
EXEC sp_configure 'xp _ Your shell', 0
RECONFIGURE WITH OVERRIDE
RECONFIGURE
EXEC sp_configure 'show advanced options', 0
RECONFIGURE WITH OVERRIDE
RECONFIGURE

OK. You can get the Remote Desktop again.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.