Is there any way to detect whether Windows 10 servers are running headed or headless mode using the command line? What thing get change when the user disconnects himself from the window server?
Query session
should provide whether the user disconnected from RDP or logged out from the console, but with other remote access solutions there is no universal indication.
Here's an example of query session on a computer with an active console session (not headless):
C:\Users\foo>query session
SESSIONNAME USERNAME ID STATE TYPE DEVICE
services 0 Disc
>console foo 1 Active
31c5ce94259d4... 65536 Listen
rdp-tcp 65538 Listen
and here's a counterexample of using psexec
to get the output of query session
from a machine with disconnected RDP users, and no one on the console session:
C:\Users\administrator>psexec \\target -s query session
PsExec v2.2 - Execute processes remotely
Copyright (C) 2001-2016 Mark Russinovich
Sysinternals - www.sysinternals.com
SESSIONNAME USERNAME ID STATE TYPE DEVICE
>services 0 Disc
console 1 Conn
jsmith 3 Disc
Administrator 12 Disc
rdp-tcp 65536 Listen
query exited on target with error code 1.
The definition of "headless" is also somewhat fraught, since VGA does not require backwards signaling, so if a server has no monitor connected, but is logged in and outputting video - is it "headless"? Does it know that it is headless?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.