How to properly quit from a Remote-Desktop Session? tsdiscon now logs the local user with priority












1















I have been using the command tsdiscon happily for disconnecting from a remote desktop connection. I have made a "bat-file" with this line, and have assigned a shortcut to this function. Now, I have trouble using the command on Windows 10 machines.



Old usage



With tsdiscon, I can happily sign off from RDP connection in two cases:




  1. When I am in the RDP session, I will exit the RDP session

  2. When I am at the local machine, the RDP session will also get terminated. Yet, nothing will happen to the local machine


Current problem



Lately, maybe due to Windows 10 updates, issuing this command in the remote desktop session will sign off not only from the RDP session, but also the local machine. This is a bit annoying. Correspondingly, when I issue the command tsdiscon in both cases:




  1. If I am in the RDP session, I will get not only signed off from the that remote session, but also the local machine

  2. If I am at the local machine, I will get signed off on both machines as well.


Solution?



Can I pass in the specific session name that I would like tsdiscon to terminate? Or, should there be a certain parameter that stipulates at which scope this command shall take effect?



So far, same command (tsdiscon) is working in the same old way on Windows 7 machines. It become buggy when I start to use a Windows 10 machine to start remote desktop session.










share|improve this question



























    1















    I have been using the command tsdiscon happily for disconnecting from a remote desktop connection. I have made a "bat-file" with this line, and have assigned a shortcut to this function. Now, I have trouble using the command on Windows 10 machines.



    Old usage



    With tsdiscon, I can happily sign off from RDP connection in two cases:




    1. When I am in the RDP session, I will exit the RDP session

    2. When I am at the local machine, the RDP session will also get terminated. Yet, nothing will happen to the local machine


    Current problem



    Lately, maybe due to Windows 10 updates, issuing this command in the remote desktop session will sign off not only from the RDP session, but also the local machine. This is a bit annoying. Correspondingly, when I issue the command tsdiscon in both cases:




    1. If I am in the RDP session, I will get not only signed off from the that remote session, but also the local machine

    2. If I am at the local machine, I will get signed off on both machines as well.


    Solution?



    Can I pass in the specific session name that I would like tsdiscon to terminate? Or, should there be a certain parameter that stipulates at which scope this command shall take effect?



    So far, same command (tsdiscon) is working in the same old way on Windows 7 machines. It become buggy when I start to use a Windows 10 machine to start remote desktop session.










    share|improve this question

























      1












      1








      1








      I have been using the command tsdiscon happily for disconnecting from a remote desktop connection. I have made a "bat-file" with this line, and have assigned a shortcut to this function. Now, I have trouble using the command on Windows 10 machines.



      Old usage



      With tsdiscon, I can happily sign off from RDP connection in two cases:




      1. When I am in the RDP session, I will exit the RDP session

      2. When I am at the local machine, the RDP session will also get terminated. Yet, nothing will happen to the local machine


      Current problem



      Lately, maybe due to Windows 10 updates, issuing this command in the remote desktop session will sign off not only from the RDP session, but also the local machine. This is a bit annoying. Correspondingly, when I issue the command tsdiscon in both cases:




      1. If I am in the RDP session, I will get not only signed off from the that remote session, but also the local machine

      2. If I am at the local machine, I will get signed off on both machines as well.


      Solution?



      Can I pass in the specific session name that I would like tsdiscon to terminate? Or, should there be a certain parameter that stipulates at which scope this command shall take effect?



      So far, same command (tsdiscon) is working in the same old way on Windows 7 machines. It become buggy when I start to use a Windows 10 machine to start remote desktop session.










      share|improve this question














      I have been using the command tsdiscon happily for disconnecting from a remote desktop connection. I have made a "bat-file" with this line, and have assigned a shortcut to this function. Now, I have trouble using the command on Windows 10 machines.



      Old usage



      With tsdiscon, I can happily sign off from RDP connection in two cases:




      1. When I am in the RDP session, I will exit the RDP session

      2. When I am at the local machine, the RDP session will also get terminated. Yet, nothing will happen to the local machine


      Current problem



      Lately, maybe due to Windows 10 updates, issuing this command in the remote desktop session will sign off not only from the RDP session, but also the local machine. This is a bit annoying. Correspondingly, when I issue the command tsdiscon in both cases:




      1. If I am in the RDP session, I will get not only signed off from the that remote session, but also the local machine

      2. If I am at the local machine, I will get signed off on both machines as well.


      Solution?



      Can I pass in the specific session name that I would like tsdiscon to terminate? Or, should there be a certain parameter that stipulates at which scope this command shall take effect?



      So far, same command (tsdiscon) is working in the same old way on Windows 7 machines. It become buggy when I start to use a Windows 10 machine to start remote desktop session.







      windows-7 windows windows-10 command-line remote-desktop






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Apr 16 '17 at 14:18









      llinfengllinfeng

      283114




      283114






















          1 Answer
          1






          active

          oldest

          votes


















          0














          This is an attempt to answer my own questions asked almost 2 years ago. I am still using RDP on a daily basis, and have spent more time reading about the tsdiscon command.



          Shorter answer



          First, let me answer the original question. According to its documentation, the tsdiscon command does take a range of parameters, including SessionName and SessionId. Issuing query session command through the command prompt shall reveal these two fields.



          PS C:WINDOWSsystem32> query session
          SESSIONNAME USERNAME ID STATE TYPE DEVICE
          services 0 Disc
          >rdp-tcp#84 Your_Username 1 Active
          console 3 Conn
          rdp-tcp 65536 Listen


          Up to an hour before typing up this answer, I have been confused by where should one issue the tsdiscon command: the original confusion in the question signifies a particular misunderstanding ==> the tsdiscon command is not supposed to be issued from a local machine when this local machine is a personal computer. This is more true when I am the single user of this local personal computer. I bet the intended usage of tsdiscon is for server admin to kick people off from their server :)





          Still, I think it is worth the time to discuss how to properly get back from remote RDP sessions. For now, I am taking a AutoHotKey-approach that comes in two parts: 1. to get back from RDP session; and then 2. to kill the local session of RDP from the local machine.



          Better way out



          Part 1: getting back from the remote RDP session



          For now, I have devised the following shortcut to get me back from a RDP session. While keeping the identical script running both the local machine and the remote RDP-connected machine, pressing Ctrl + CapsLock (Ctrl first, then Capslock) shall "hide" the RDP session, and almost always restore keyboard focus + mouse focus back to the local machine.



          ; The following are AutoHotKey scripts.
          #IfWinActive ahk_class TscShellContainerClass
          ^Capslock::
          Sleep 50
          WinMinimize
          return
          #IfWinActive
          ; Make-shift script as suggested by: https://autohotkey.com/boards/viewtopic.php?t=25432
          ; May solve the awkward loss-of-focus when returning back from RDP
          ^Capslock::
          WinGetClass activeclass, A
          WinGetTitle activetitle, A
          MsgBox, 48, Warning, %activetitle% ahk_class %activeclass%, 0.666666
          return


          Simple solution to "kill" RDP session



          As the Ctrl + CapsLock shortcut should be working 99% of the times, I then simplify the task as: kill the existing RDP session. Again, AutoHotKey comes handy, as I may have multiple RDP sessions to different machines running, and I shall only need to kill one of them.



          #+y:: 
          WinClose, <Session 1: name_of_the_saved_RDP_config_file> - Remote Desktop Connection
          WinClose, <Session 2: name_of_the_saved_RDP_config_file> - Remote Desktop Connection
          return


          One would need to carefully substitute the <Session 1...> portion of the AHK script. It needs to match the Window-Title of the RDP session when it is active. I usually look it up using the following procedures:
          1. Open an RDP session in a Window, i.e. without having it span all active monitors
          2. Open "Windows Spy", an AHK-utility that reveals all identifiers for a "window": full set of identifiers include Window-Title, process_name and win_class_name.





          PS: during my weekly home(-code-)improvement session, I headed out to solve the tsdiscon issue again. With very similar query terms, I am happy to re-discover this old question. With a bit more careful reading of the documentation, it became apparent that I should not bet on one single command to handle all usages of mine. Thus come this pro-longed answer. Hope it can help people who play with RDP a lot.






          share|improve this answer























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "3"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1200200%2fhow-to-properly-quit-from-a-remote-desktop-session-tsdiscon-now-logs-the-local%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            This is an attempt to answer my own questions asked almost 2 years ago. I am still using RDP on a daily basis, and have spent more time reading about the tsdiscon command.



            Shorter answer



            First, let me answer the original question. According to its documentation, the tsdiscon command does take a range of parameters, including SessionName and SessionId. Issuing query session command through the command prompt shall reveal these two fields.



            PS C:WINDOWSsystem32> query session
            SESSIONNAME USERNAME ID STATE TYPE DEVICE
            services 0 Disc
            >rdp-tcp#84 Your_Username 1 Active
            console 3 Conn
            rdp-tcp 65536 Listen


            Up to an hour before typing up this answer, I have been confused by where should one issue the tsdiscon command: the original confusion in the question signifies a particular misunderstanding ==> the tsdiscon command is not supposed to be issued from a local machine when this local machine is a personal computer. This is more true when I am the single user of this local personal computer. I bet the intended usage of tsdiscon is for server admin to kick people off from their server :)





            Still, I think it is worth the time to discuss how to properly get back from remote RDP sessions. For now, I am taking a AutoHotKey-approach that comes in two parts: 1. to get back from RDP session; and then 2. to kill the local session of RDP from the local machine.



            Better way out



            Part 1: getting back from the remote RDP session



            For now, I have devised the following shortcut to get me back from a RDP session. While keeping the identical script running both the local machine and the remote RDP-connected machine, pressing Ctrl + CapsLock (Ctrl first, then Capslock) shall "hide" the RDP session, and almost always restore keyboard focus + mouse focus back to the local machine.



            ; The following are AutoHotKey scripts.
            #IfWinActive ahk_class TscShellContainerClass
            ^Capslock::
            Sleep 50
            WinMinimize
            return
            #IfWinActive
            ; Make-shift script as suggested by: https://autohotkey.com/boards/viewtopic.php?t=25432
            ; May solve the awkward loss-of-focus when returning back from RDP
            ^Capslock::
            WinGetClass activeclass, A
            WinGetTitle activetitle, A
            MsgBox, 48, Warning, %activetitle% ahk_class %activeclass%, 0.666666
            return


            Simple solution to "kill" RDP session



            As the Ctrl + CapsLock shortcut should be working 99% of the times, I then simplify the task as: kill the existing RDP session. Again, AutoHotKey comes handy, as I may have multiple RDP sessions to different machines running, and I shall only need to kill one of them.



            #+y:: 
            WinClose, <Session 1: name_of_the_saved_RDP_config_file> - Remote Desktop Connection
            WinClose, <Session 2: name_of_the_saved_RDP_config_file> - Remote Desktop Connection
            return


            One would need to carefully substitute the <Session 1...> portion of the AHK script. It needs to match the Window-Title of the RDP session when it is active. I usually look it up using the following procedures:
            1. Open an RDP session in a Window, i.e. without having it span all active monitors
            2. Open "Windows Spy", an AHK-utility that reveals all identifiers for a "window": full set of identifiers include Window-Title, process_name and win_class_name.





            PS: during my weekly home(-code-)improvement session, I headed out to solve the tsdiscon issue again. With very similar query terms, I am happy to re-discover this old question. With a bit more careful reading of the documentation, it became apparent that I should not bet on one single command to handle all usages of mine. Thus come this pro-longed answer. Hope it can help people who play with RDP a lot.






            share|improve this answer




























              0














              This is an attempt to answer my own questions asked almost 2 years ago. I am still using RDP on a daily basis, and have spent more time reading about the tsdiscon command.



              Shorter answer



              First, let me answer the original question. According to its documentation, the tsdiscon command does take a range of parameters, including SessionName and SessionId. Issuing query session command through the command prompt shall reveal these two fields.



              PS C:WINDOWSsystem32> query session
              SESSIONNAME USERNAME ID STATE TYPE DEVICE
              services 0 Disc
              >rdp-tcp#84 Your_Username 1 Active
              console 3 Conn
              rdp-tcp 65536 Listen


              Up to an hour before typing up this answer, I have been confused by where should one issue the tsdiscon command: the original confusion in the question signifies a particular misunderstanding ==> the tsdiscon command is not supposed to be issued from a local machine when this local machine is a personal computer. This is more true when I am the single user of this local personal computer. I bet the intended usage of tsdiscon is for server admin to kick people off from their server :)





              Still, I think it is worth the time to discuss how to properly get back from remote RDP sessions. For now, I am taking a AutoHotKey-approach that comes in two parts: 1. to get back from RDP session; and then 2. to kill the local session of RDP from the local machine.



              Better way out



              Part 1: getting back from the remote RDP session



              For now, I have devised the following shortcut to get me back from a RDP session. While keeping the identical script running both the local machine and the remote RDP-connected machine, pressing Ctrl + CapsLock (Ctrl first, then Capslock) shall "hide" the RDP session, and almost always restore keyboard focus + mouse focus back to the local machine.



              ; The following are AutoHotKey scripts.
              #IfWinActive ahk_class TscShellContainerClass
              ^Capslock::
              Sleep 50
              WinMinimize
              return
              #IfWinActive
              ; Make-shift script as suggested by: https://autohotkey.com/boards/viewtopic.php?t=25432
              ; May solve the awkward loss-of-focus when returning back from RDP
              ^Capslock::
              WinGetClass activeclass, A
              WinGetTitle activetitle, A
              MsgBox, 48, Warning, %activetitle% ahk_class %activeclass%, 0.666666
              return


              Simple solution to "kill" RDP session



              As the Ctrl + CapsLock shortcut should be working 99% of the times, I then simplify the task as: kill the existing RDP session. Again, AutoHotKey comes handy, as I may have multiple RDP sessions to different machines running, and I shall only need to kill one of them.



              #+y:: 
              WinClose, <Session 1: name_of_the_saved_RDP_config_file> - Remote Desktop Connection
              WinClose, <Session 2: name_of_the_saved_RDP_config_file> - Remote Desktop Connection
              return


              One would need to carefully substitute the <Session 1...> portion of the AHK script. It needs to match the Window-Title of the RDP session when it is active. I usually look it up using the following procedures:
              1. Open an RDP session in a Window, i.e. without having it span all active monitors
              2. Open "Windows Spy", an AHK-utility that reveals all identifiers for a "window": full set of identifiers include Window-Title, process_name and win_class_name.





              PS: during my weekly home(-code-)improvement session, I headed out to solve the tsdiscon issue again. With very similar query terms, I am happy to re-discover this old question. With a bit more careful reading of the documentation, it became apparent that I should not bet on one single command to handle all usages of mine. Thus come this pro-longed answer. Hope it can help people who play with RDP a lot.






              share|improve this answer


























                0












                0








                0







                This is an attempt to answer my own questions asked almost 2 years ago. I am still using RDP on a daily basis, and have spent more time reading about the tsdiscon command.



                Shorter answer



                First, let me answer the original question. According to its documentation, the tsdiscon command does take a range of parameters, including SessionName and SessionId. Issuing query session command through the command prompt shall reveal these two fields.



                PS C:WINDOWSsystem32> query session
                SESSIONNAME USERNAME ID STATE TYPE DEVICE
                services 0 Disc
                >rdp-tcp#84 Your_Username 1 Active
                console 3 Conn
                rdp-tcp 65536 Listen


                Up to an hour before typing up this answer, I have been confused by where should one issue the tsdiscon command: the original confusion in the question signifies a particular misunderstanding ==> the tsdiscon command is not supposed to be issued from a local machine when this local machine is a personal computer. This is more true when I am the single user of this local personal computer. I bet the intended usage of tsdiscon is for server admin to kick people off from their server :)





                Still, I think it is worth the time to discuss how to properly get back from remote RDP sessions. For now, I am taking a AutoHotKey-approach that comes in two parts: 1. to get back from RDP session; and then 2. to kill the local session of RDP from the local machine.



                Better way out



                Part 1: getting back from the remote RDP session



                For now, I have devised the following shortcut to get me back from a RDP session. While keeping the identical script running both the local machine and the remote RDP-connected machine, pressing Ctrl + CapsLock (Ctrl first, then Capslock) shall "hide" the RDP session, and almost always restore keyboard focus + mouse focus back to the local machine.



                ; The following are AutoHotKey scripts.
                #IfWinActive ahk_class TscShellContainerClass
                ^Capslock::
                Sleep 50
                WinMinimize
                return
                #IfWinActive
                ; Make-shift script as suggested by: https://autohotkey.com/boards/viewtopic.php?t=25432
                ; May solve the awkward loss-of-focus when returning back from RDP
                ^Capslock::
                WinGetClass activeclass, A
                WinGetTitle activetitle, A
                MsgBox, 48, Warning, %activetitle% ahk_class %activeclass%, 0.666666
                return


                Simple solution to "kill" RDP session



                As the Ctrl + CapsLock shortcut should be working 99% of the times, I then simplify the task as: kill the existing RDP session. Again, AutoHotKey comes handy, as I may have multiple RDP sessions to different machines running, and I shall only need to kill one of them.



                #+y:: 
                WinClose, <Session 1: name_of_the_saved_RDP_config_file> - Remote Desktop Connection
                WinClose, <Session 2: name_of_the_saved_RDP_config_file> - Remote Desktop Connection
                return


                One would need to carefully substitute the <Session 1...> portion of the AHK script. It needs to match the Window-Title of the RDP session when it is active. I usually look it up using the following procedures:
                1. Open an RDP session in a Window, i.e. without having it span all active monitors
                2. Open "Windows Spy", an AHK-utility that reveals all identifiers for a "window": full set of identifiers include Window-Title, process_name and win_class_name.





                PS: during my weekly home(-code-)improvement session, I headed out to solve the tsdiscon issue again. With very similar query terms, I am happy to re-discover this old question. With a bit more careful reading of the documentation, it became apparent that I should not bet on one single command to handle all usages of mine. Thus come this pro-longed answer. Hope it can help people who play with RDP a lot.






                share|improve this answer













                This is an attempt to answer my own questions asked almost 2 years ago. I am still using RDP on a daily basis, and have spent more time reading about the tsdiscon command.



                Shorter answer



                First, let me answer the original question. According to its documentation, the tsdiscon command does take a range of parameters, including SessionName and SessionId. Issuing query session command through the command prompt shall reveal these two fields.



                PS C:WINDOWSsystem32> query session
                SESSIONNAME USERNAME ID STATE TYPE DEVICE
                services 0 Disc
                >rdp-tcp#84 Your_Username 1 Active
                console 3 Conn
                rdp-tcp 65536 Listen


                Up to an hour before typing up this answer, I have been confused by where should one issue the tsdiscon command: the original confusion in the question signifies a particular misunderstanding ==> the tsdiscon command is not supposed to be issued from a local machine when this local machine is a personal computer. This is more true when I am the single user of this local personal computer. I bet the intended usage of tsdiscon is for server admin to kick people off from their server :)





                Still, I think it is worth the time to discuss how to properly get back from remote RDP sessions. For now, I am taking a AutoHotKey-approach that comes in two parts: 1. to get back from RDP session; and then 2. to kill the local session of RDP from the local machine.



                Better way out



                Part 1: getting back from the remote RDP session



                For now, I have devised the following shortcut to get me back from a RDP session. While keeping the identical script running both the local machine and the remote RDP-connected machine, pressing Ctrl + CapsLock (Ctrl first, then Capslock) shall "hide" the RDP session, and almost always restore keyboard focus + mouse focus back to the local machine.



                ; The following are AutoHotKey scripts.
                #IfWinActive ahk_class TscShellContainerClass
                ^Capslock::
                Sleep 50
                WinMinimize
                return
                #IfWinActive
                ; Make-shift script as suggested by: https://autohotkey.com/boards/viewtopic.php?t=25432
                ; May solve the awkward loss-of-focus when returning back from RDP
                ^Capslock::
                WinGetClass activeclass, A
                WinGetTitle activetitle, A
                MsgBox, 48, Warning, %activetitle% ahk_class %activeclass%, 0.666666
                return


                Simple solution to "kill" RDP session



                As the Ctrl + CapsLock shortcut should be working 99% of the times, I then simplify the task as: kill the existing RDP session. Again, AutoHotKey comes handy, as I may have multiple RDP sessions to different machines running, and I shall only need to kill one of them.



                #+y:: 
                WinClose, <Session 1: name_of_the_saved_RDP_config_file> - Remote Desktop Connection
                WinClose, <Session 2: name_of_the_saved_RDP_config_file> - Remote Desktop Connection
                return


                One would need to carefully substitute the <Session 1...> portion of the AHK script. It needs to match the Window-Title of the RDP session when it is active. I usually look it up using the following procedures:
                1. Open an RDP session in a Window, i.e. without having it span all active monitors
                2. Open "Windows Spy", an AHK-utility that reveals all identifiers for a "window": full set of identifiers include Window-Title, process_name and win_class_name.





                PS: during my weekly home(-code-)improvement session, I headed out to solve the tsdiscon issue again. With very similar query terms, I am happy to re-discover this old question. With a bit more careful reading of the documentation, it became apparent that I should not bet on one single command to handle all usages of mine. Thus come this pro-longed answer. Hope it can help people who play with RDP a lot.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Feb 17 at 22:40









                llinfengllinfeng

                283114




                283114






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Super User!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1200200%2fhow-to-properly-quit-from-a-remote-desktop-session-tsdiscon-now-logs-the-local%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Index of /

                    Tribalistas

                    Listed building