0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Windowsでconsole sessionを残してRDP切断する方法

Last updated at Posted at 2025-04-22

はじめに

知っている人は知っている話だが、Windowsにはログオンセッションの違いによって動作が違うプログラムというのが存在する。Power Automate Desktopで書いたUI操作がいるフローとか。

セッションの種類

実機アクセスしている場合console sessionになる

C:\Users\yumetodo>query session
 セッション名      ユーザー名               ID  状態    種類        デバイス
 services                                    0  Disc
>console           yumetodo                  2  Active
 rdp-tcp                                 65537  Listen

RDPアクセスしている場合、remote sessionになる

PS C:\WINDOWS\system32> query session
 セッション名      ユーザー名               ID  状態    種類        デバイス
 services                                    0  Disc
 console                                     1  Conn
>rdp-tcp#1         yumetodo                  2  Active
 31c5ce94259d4...                        65536  Listen
 7a78855482a04...                        65537  Listen
 rdp-tcp                                 65538  Listen

リモートデスクトップで、ウィンドウを閉じて切断するとセッションがリモートセッションのままになってしまう。

tscon

そこで、管理者権限コマンドプロンプトから

tscon 1 /dest:console

のように、現在RDPしているセッションID(一つ上のquery sessionの結果の場合2になる)をコンソールセッションに切り替えることでRDPを切断するとうまくいくことがある。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?