<p>Meilleure solution : un agent de sécurité escorte la personne dehors…</p>
<p>Deuxième meilleure solution :</p>
<ul>
<li>
<p>D’abord, vérifiez le numéro de session avec qwinsta : QWINSTA /server:nom_ordinateur</p>
</li>
<li>
<p>Notez l’identifiant de session.</p>
</li>
<li>
<p>Ensuite, utilisez la commande logoff : LOGOFF sessionID /server:nom_ordinateur.</p>
</li>
</ul>
<blockquote></blockquote>
<pre><code class="lang-auto">C:>qwinsta /?
Display information about Remote Desktop Sessions.
QUERY SESSION [sessionname | username | sessionid]
[/SERVER:servername] [/MODE] [/FLOW] [/CONNECT] [/COUNTER] [/VM]
sessionname Identifies the session named sessionname.
username Identifies the session with user username.
sessionid Identifies the session with ID sessionid.
/SERVER:servername The server to be queried (default is current).
/MODE Display current line settings.
/FLOW Display current flow control settings.
/CONNECT Display current connect settings.
/COUNTER Display current Remote Desktop Services counters information.
/VM Display information about sessions within virtual machines.
C:>logoff /?
Terminates a session.
LOGOFF [sessionname | sessionid] [/SERVER:servername] [/V] [/VM]
sessionname The name of the session.
sessionid The ID of the session.
/SERVER:servername Specifies the Remote Desktop server containing the user
session to log off (default is current).
/V Displays information about the actions performed.
/VM Logs off a session on server or within virtual machine. The unique ID of the session needs to be specified.
</code></pre>
<p>J’ai écrit un script batch rudimentaire pour cela. Il nécessite des <code>unixtools</code> dans le PATH ainsi que <code>psexec</code>.</p>
<pre><code class="lang-auto">@ECHO OFF
:: Script to log a user off a remote machine
::
:: Param 1: The machine
:: Param 2: The username
psexec \%1 qwinsta | grep %2 | sed 's/console//' | awk '{print $2}' > %tmp%\sessionid.txt
set /p sessionid=< %tmp%\sessionid.txt
del /q %tmp%\sessionid.txt
psexec \%1 logoff %sessionid% /v
</code></pre>