INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Cleanly disconnecting from RDP and returning MC to "family use"  (Read 9082 times)

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4217

I thought I'd share this in case it helps anyone. I've always steered clear of Remote Desktop for remoting into my main HTPC because it locks the screen on exit however I have found all flavours of VNC to have problems & Teamviewer is just too slow (and annoying with the popup it shows when you exit). I finally found a solution that seems to work well so here it is

Create a file named disconnect.bat and put the following in there

MC20.exe /Mode Theater
tscon.exe 1 /dest:console

save this and give it admin rights to execute

Run this whenever you want to leave the PC and it will return the HTPC back to a state that your family can cope with!

credit to http://blog.chlaird.com/2012/02/heres-how-i-spent-my-monday-night.html for the tscon bit
Logged

AndrewFG

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3392
Re: Cleanly disconnecting from RDP and returning MC to "family use"
« Reply #1 on: April 18, 2015, 03:52:41 am »

Cool. I will give it a try.
Logged
Author of Whitebear Digital Media Renderer Analyser - http://www.whitebear.ch/dmra.htm
Author of Whitebear - http://www.whitebear.ch/mediaserver.htm

Arindelle

  • Citizen of the Universe
  • *****
  • Posts: 2772
Re: Cleanly disconnecting from RDP and returning MC to "family use"
« Reply #2 on: April 18, 2015, 04:05:03 am »

Teamviewer is really much faster for me than RDC, but those pop-up left behind are pretty bad, I'm going to try it too. Thanks!
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9133
Re: Cleanly disconnecting from RDP and returning MC to "family use"
« Reply #3 on: April 18, 2015, 05:45:45 am »

I've been using tscon for four years now... since MC15!!
http://yabb.jriver.com/interact/index.php?topic=62548.0

Works a treat.

kstuart

  • Citizen of the Universe
  • *****
  • Posts: 1955
  • Upgraded to MC22 Master using preorder discount
Re: Cleanly disconnecting from RDP and returning MC to "family use"
« Reply #4 on: April 18, 2015, 02:51:26 pm »

I use RealVNC and have no problems.   What problems do you have ?

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Cleanly disconnecting from RDP and returning MC to "family use"
« Reply #5 on: April 18, 2015, 03:02:47 pm »

Teamviewer is really much faster for me than RDC

TeamViewer is actually fast enough for me to watch video playing on my main computer using TeamViewer on my iPad or Laptop.  I think they do some magic to optimize for video, but it works, and browsing around in Standard View and Theater View both also work decently well.

I really like it.  I'd happily pay for a "home user" license that would let me access my own machines and family's machines occasionally (the family tech nerd style) to get rid of the popups if they didn't want to charge me like I'm a company.  But not at $750!  :o
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5233
  • "Linux Merit Badge" Recipient
Re: Cleanly disconnecting from RDP and returning MC to "family use"
« Reply #6 on: April 18, 2015, 03:07:34 pm »

Man I must just be on Mars; teamviewer has always been dog slow for me (with compromised color to boot) and RDP has been ok, but not particularly reliable (it's fine windows to windows, but cross-platform it has made me crazy more than once).

VNC is the only thing I've ever gotten stable, acceptable performance with.  But very few other people seem to have positive feelings about it. 

I guess a lot must depend on use cases; I feel like the blind man with the elephant.
Logged

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4217
Re: Cleanly disconnecting from RDP and returning MC to "family use"
« Reply #7 on: April 18, 2015, 03:27:03 pm »

I have used vnc for years with no issues but, on this windows 8.1 machine, it turned into a cpu hog. I tried a few different VNCs (realvnc, tightvnc, possibly ultra? I forget) but they all went bad. I also found KRDC to VNC to suffer from random lockups but could never work out which side had the problem.

Teamviewer is ok but the popups kill it, it also does this annoying switch focus thing so that I have to keep clicking back onto the window I'm on to reactivate focus. This makes it annoying to use on a keyboard driven app.

RDP was always silky smooth for me, just the lockscreen thing was so dumb (albeit don't get me started on the single user restriction in windows).

Logged

DSCabrio

  • Recent member
  • *
  • Posts: 7
Re: Cleanly disconnecting from RDP and returning MC to "family use"
« Reply #8 on: April 18, 2015, 08:11:25 pm »

You can also add multiple tscon commands so if you log in more than once as the same user on a machine or to a different machine you can continue to avoid locking  the client.

tscon 0 /dest:console
tscon 1 /dest:console
tscon 2 /dest:console
tscon 3 /dest:console
tscon 4 /dest:console

Tip from http://www.reddit.com/r/windows/comments/28bwel/when_remoting_into_81_over_rdp_you_can_hand_your/
Logged

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Cleanly disconnecting from RDP and returning MC to "family use"
« Reply #9 on: April 19, 2015, 04:14:27 am »

MC20.exe /Mode Theater
tscon.exe 1 /dest:console

Oh, I really wanted this to work, but I kept getting "Access Denied" or other permission problems. I tried everything. All sorts of "Run as Administrator" methods, which I won't bother describing.

I must have a slightly different setup to other people. My HTPC runs a non-Administrator account called "htpc", and I Remote into the HTPC from my main desktop PC, which runs a different account name, which is an Administrator. When I remotely connect I use the "htpc" account on my HTPC. I also tried remotely connecting to the HTPC using the same Administrator account as I use on the desktop. That account is also set up on the HTPC for when I need Administrator rights.

The results of several different methods are shown in the image below. None worked.

Finally I clicked on what was required. The batch file needed to include the password for the "htpc" account on the HTPC. So the new batch file is:
Code: [Select]
MC20.exe /Mode Theater
tscon.exe 1 /dest:console /PASSWORD:secretpassword

The shortcut to this batch file, which I have placed on the Desktop, is set to run as Administrator, and when run asks for the Administrator user password. It then closes the Remote Desktop session with the warning message shown in the second image. Back on my HTPC MC is up and running in Theater View.

Neat. Thanks so much for sharing. Much less annoying than having to walk back to the HTPC and log back into the "htpc" user account, even though I still have to enter a password.

EDIT: A quick correction in blue above, in case someone is going to write a Wiki. The batch file itself can't be set to Run As Administrator, but the shortcut to it can.
Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4217
Re: Cleanly disconnecting from RDP and returning MC to "family use"
« Reply #10 on: April 19, 2015, 08:12:00 am »

This looks worth a wiki entry to me, would anyone (with wiki write  access) mind writing something to summarise?
Logged

hollidayjr

  • Recent member
  • *
  • Posts: 14
  • Never Give Up
Re: Cleanly disconnecting from RDP and returning MC to "family use"
« Reply #11 on: April 20, 2015, 09:55:41 am »

The latest version of Teamviewer has removed all the popups!!
Logged

BartMan01

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1513
Re: Cleanly disconnecting from RDP and returning MC to "family use"
« Reply #12 on: April 20, 2015, 10:15:10 am »

Teamviewer is really much faster for me than RDC, but those pop-up left behind are pretty bad, I'm going to try it too. Thanks!

https://www.bing.com/search?q=teamviewer+autoit3&pc=MOZI&form=MOZSBR


You can use AutoIt3 to auto-close the pop-up.  I use that solution on my HTPC, I don't mind it on regular PCs.
Logged

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4217
Re: Cleanly disconnecting from RDP and returning MC to "family use"
« Reply #13 on: April 20, 2015, 10:32:21 am »

The latest version of Teamviewer has removed all the popups!!
which version? I was using the latest (v10 something) til last week & it had popups.
Logged

BartMan01

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1513
Re: Cleanly disconnecting from RDP and returning MC to "family use"
« Reply #14 on: April 20, 2015, 11:09:21 am »

The latest version of Teamviewer has removed all the popups!!

Just checked for updates.  Seems this the case for the recent update to Windows, but OSX still has pop-ups still.  Going to keep my 'auto close' program in place for now in case it was just a mistake and not done on purpose.
Logged

zydeco

  • Junior Woodchuck
  • **
  • Posts: 88
Re: Cleanly disconnecting from RDP and returning MC to "family use"
« Reply #15 on: April 21, 2015, 04:34:50 pm »

I've tried the suggested approach with the disconnect.bat file put on the HTPC which, when finished, I "run as administrator". This does return the HTPC to Theatre View but a password is still required to get onto the machine (following log-off via Remote Desktop). Is it possible to automate the entire process such that the HTPC is returned to Theatre View and logged on so that the family doesn't need to do anything at all?
Logged

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Cleanly disconnecting from RDP and returning MC to "family use"
« Reply #16 on: April 21, 2015, 07:39:24 pm »

When I run the batch file on my HTPC, no re-logon is required.

Before I start the remote connection the HTPC is sitting in Theatre View of MC.
While I am remotely connected the HTPC shows the User selection screen of the Windows login process.
When I run Disconnect.bat the HTPC returns to MC showing Theatre View.

You should not need to log-off via Remote Desktop. The command "tscon.exe 1 /dest:console /PASSWORD:secretpassword" does the logoff for you.
Note, as per my post above, I needed to include the password in the command. It is the password of the User ID that I am using for the remote connection on the HTPC.
Note also that you need to get the correct Session ID for use in the command. Mine is set to "1", but yours may be different. You can use in the command "query user" in a CMD window of the remote connection to confirm the correct Session ID. You can see how that works in the image I posted above. You need the Session ID of the User ID on the HTPC, not the Session ID of the remote connection.

The command basically reconnects the original session of the HTPC user back to the Console, which is the output to a screen. In doing so it forces the remote connection to close, as it no longer has a output to connect to, which is its sole purpose.

As you say you still have to enter a password to get onto the machine, and you still need to log-off via Remote Desktop, it sounds like the tscon command is not working for you. Adding the password may fix the problem.

PS: Note that I have the batch file stored in a sub-directory on my HTPC, not on the Desktop or in a Windows related directory, and have a shortcut to that batch file on my Desktop. That enables me to set the shortcut to always "Run as Administrator", so I don't have to right click or anything. Of course running as administrator does still require an administrator password to be entered at run time.
Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner

Arindelle

  • Citizen of the Universe
  • *****
  • Posts: 2772
Re: Cleanly disconnecting from RDP and returning MC to "family use"
« Reply #17 on: April 22, 2015, 06:43:31 am »

I tried ... its too slow for me ... and I need TeamViewer to help other people - this would be way too complicated for non-geeks. So back to Teamviewer for me.

The latest version of Teamviewer has removed all the popups!!
hmm I have the latest and the pop-up stays on the remote computer. What version are you running? I'm using 10.0.41459 and it says its the most recent  -- are there 64 and 32 bit versions maybe? (I'm on a Win7 64bit)
Logged

hollidayjr

  • Recent member
  • *
  • Posts: 14
  • Never Give Up
Re: Cleanly disconnecting from RDP and returning MC to "family use"
« Reply #18 on: April 22, 2015, 01:52:34 pm »

I have the same version of Teamviewer -both client and server run Win 8.1(64Bit) with no popups on either machine.
Logged

Arindelle

  • Citizen of the Universe
  • *****
  • Posts: 2772
Re: Cleanly disconnecting from RDP and returning MC to "family use"
« Reply #19 on: April 22, 2015, 02:26:54 pm »

I have the same version of Teamviewer -both client and server run Win 8.1(64Bit) with no popups on either machine.
ok thanks, one of those mysteries I guess

this is the pop-up I was talking about btw

Logged

zydeco

  • Junior Woodchuck
  • **
  • Posts: 88
Re: Cleanly disconnecting from RDP and returning MC to "family use"
« Reply #20 on: April 27, 2015, 06:45:11 am »

When I run the batch file on my HTPC, no re-logon is required.

Before I start the remote connection the HTPC is sitting in Theatre View of MC.
While I am remotely connected the HTPC shows the User selection screen of the Windows login process.
When I run Disconnect.bat the HTPC returns to MC showing Theatre View.

You should not need to log-off via Remote Desktop. The command "tscon.exe 1 /dest:console /PASSWORD:secretpassword" does the logoff for you.
Note, as per my post above, I needed to include the password in the command. It is the password of the User ID that I am using for the remote connection on the HTPC.
Note also that you need to get the correct Session ID for use in the command. Mine is set to "1", but yours may be different. You can use in the command "query user" in a CMD window of the remote connection to confirm the correct Session ID. You can see how that works in the image I posted above. You need the Session ID of the User ID on the HTPC, not the Session ID of the remote connection.

The command basically reconnects the original session of the HTPC user back to the Console, which is the output to a screen. In doing so it forces the remote connection to close, as it no longer has a output to connect to, which is its sole purpose.

As you say you still have to enter a password to get onto the machine, and you still need to log-off via Remote Desktop, it sounds like the tscon command is not working for you. Adding the password may fix the problem.

PS: Note that I have the batch file stored in a sub-directory on my HTPC, not on the Desktop or in a Windows related directory, and have a shortcut to that batch file on my Desktop. That enables me to set the shortcut to always "Run as Administrator", so I don't have to right click or anything. Of course running as administrator does still require an administrator password to be entered at run time.

Thanks - all working now after making sure that I was disconnecting the correct session and adding the password
Logged
Pages: [1]   Go Up