重现步骤:
- Login to a Windows 2008 R2 via RDP - Open a "Command Prompt" - Type: qwinsta - Get: SESSIONNAME USERNAME ID STATE TYPE DEVICE services 0 Disc console 1 Conn >rdp-tcp#0 Administrator 2 Active rdpwd rdp-tcp 65536 Listen - Type: tscon 1 /v - Get: Connecting sessionID 1 to sessionname RDP-Tcp#0 Could not connect sessionID 1 to this session, Error code 5023 Error [5023]:The group or resource is not in the correct state to perform the re quested operation. - Type: logoff - Get disconnected from the Server - Connect again to the Machine via RDP - Open a "Command Prompt" - Type: qwinsta - Get: SESSIONNAME USERNAME ID STATE TYPE DEVICE services 0 Disc >rdp-tcp#0 Administrator 1 Active rdpwd console 3 Conn rdp-tcp 65536 Listen - Type: shutdown -r - Get a Restart - Wait and reconnect via RDP - Open a "Command Prompt" - Type: qwinsta - Get: SESSIONNAME USERNAME ID STATE TYPE DEVICE services 0 Disc console 1 Conn >rdp-tcp#0 Administrator 2 Active rdpwd rdp-tcp 65536 Listen
第一个qwinsta给我在会话ID 1的console和在会话ID 2的Administrator (RDP) 。 我执行tscon 1 /v命令并注销login后,我得到了console的会话ID 2和Adminsitrator (RDP)的会话ID 1 。 如果我然后重新启动所有会话回到1为console和2为RDP 。 问题: 如何将console永久设置为会话ID 2和Administrator (RDP)为会话ID 1 ?
不幸的是我不能自动化。 我在Jenkins环境中使用PSExec。 为此,我仍然需要configurationWIndows 2008,使用ID 1作为pipe理员,使用2作为控制台。
解:
如果您为pipe理员启用自动login,它仍然按预期工作。
- Activate "Auto Login" for the Administrator - Regedit: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon - AutoAdminLogon=1 - Command Prompt: control userpasswords2 - Activate "User must enter a user name and password to use this computer." - Deactivate "User must enter a user name and password to use this computer." - Click OK - Enter Password two times - Click OK - Restart Machine