重现步骤:
- 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
给了我 的console
会话 ID1
和Administrator (RDP)
的会话 ID 2
。在我执行tscon 1 /v
命令并注销并再次登录后,我得到了 的会话 ID2
和的console
会话 ID 。如果我重新启动,所有的会话都会恢复到和的会话ID 。问题:1
Adminsitrator (RDP)
1
console
2
RDP
我如何才能永久设置console
会话 ID2
和Administrator (RDP)
会话 ID ?1
不幸的是我无法实现自动化。我在 Jenkins 环境中使用 PSExec。为此我仍然需要配置 WIndows 2008,以便它使用1
管理员和2
控制台的 ID。
解决方案:
如果您为管理员启用自动登录,它仍可按预期工作。
- 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