STEAM GROUP
Steam Remote Play homestream
STEAM GROUP
Steam Remote Play homestream
2,135
IN-GAME
30,956
ONLINE
Founded
November 7, 2013
amorpheous May 16, 2015 @ 6:58am
Guide: Unlock a Windows host screen using Remote Desktop & a simple script.
TL;DR
Run this script as administrator:

@powershell -NoProfile -ExecutionPolicy unrestricted -Command "$sessionid=((quser $env:USERNAME | select -Skip 1) -split '\s+')[2]; tscon $sessionid /dest:console" 2> UnlockErrors.log

Who is this guide for?

  • Security conscious users who DO NOT want to set up auto-login on their host Windows machines.
  • Users who use Remote Desktop to connect to their host machines (OPTIONAL - see Pre-requisites)
  • Users who keep their host machines always on OR use Wake-On-LAN to switch their host machines on remotely.
  • Lazy people like me who can't be bothered to walk two rooms over to unlock the host machines' screen in person.

Pre-requisites

  • Your host machine must be switched on (duh).
  • Your host machine must have Remote Desktop enabled and you must be able to login to it. If your client is a Windows machine you can use PsExec instead of using Remote Desktop. However, my client is a Mac so I need to use Remote Desktop. I may write a PsExec script which can be invoked from the client at some point, but I don't need it and I'm lazy so it might be a while (or never).
  • The user account you use to login to your host machine must have administrator privileges.

Putting It All Together

  1. Paste the script at the top into a text file and save it somewhere. I named mine UnlockScreen.cmd and saved it in my user directory.
  2. Create a shortcut to the script on your desktop or somewhere you can easily double-click on it from.
  3. Right-click the shortcut and bring up the Properties page.
  4. Click Advanced on the Shortcut tab
  5. Check the "Run as Administrator" checkbox and click OK
  6. Click OK again on the Properties page

Usage
  1. Remote into your machine and double-click the script. That's it. Simples.

NOTE: When you run the script, if it is successful your Remote Desktop session will end and will be disconnected. However, your host machine's screen will now be unlocked and you should be able to use Steam In-Home Streaming without Steam complaining with "The screen is locked on the remote computer" error.

Additional caveats - This has only been tested on a Windows 8.1 (now upgraded to Windows 10) Pro host machine. In theory it should work on Windows 7 and Windows 8 too, but if you have any issues have a look for anything obvious in the UnlockErrors.log file otherwise post here and I'll try to help if I can.

As noted here by mattrummins, the script will not work on Home versions of Windows.
Last edited by amorpheous; Jan 8, 2017 @ 5:03pm
< >
Showing 61-75 of 77 comments
`digitaL.braVo Sep 7, 2017 @ 11:18pm 
Originally posted by mattrummins:
Originally posted by billy:
Hello !
I'm seeking help from the wise members of this community.
I would like to start Steam in bigpicture before closing the RDP connection with this script:
cd "C:\Program Files (x86)\Steam\"
tasklist|>nul find /i "Steam.exe"
if errorlevel 1 (start Steam.exe -bigpicture) else (start Steam.exe "steam://open/bigpicture")
But I can't seem to integrate it with the provided script of this thread.
Has anyone done something similar or has a solution ?
Note: Both script works well and the combination works as well not launched from RDP connection
Thanks in advance for the help

Hi billy, did you solve this? If not, you can do it by using run command (windows key + R) to run the script. You will have to tell the script to run as admin by default (right click the file and go properties), and then you will have to confirm 'yes' when the obnoxious windows popup asks if you want to allow the program, but it should work if you get all these bits sorted out.

Out of interest, why do you want to do this?
People leave UAC on??
Ascending Anus Sep 29, 2017 @ 3:10pm 
My login has an @ in it and I think it's messing this up.

Can anyone help? Just not familiar enough with syntax...

Log below.

No User exists for @gmail.com
Invalid parameter(s)
Attaches a user session to a remote desktop session.

TSCON {sessionid | sessionname} [/dest:sessionname]
[/password:pw] [/v]

sessionid The ID of the session.
sessionname The name of the session.
/DEST:sessionname Connect the session to destination sessionname.
/PASSWORD:pw Password of user owning identified session.
/V Displays information about the actions performed.

amorpheous Oct 25, 2017 @ 3:59am 
Originally posted by Ascending Anus:
My login has an @ in it and I think it's messing this up.

Can anyone help? Just not familiar enough with syntax...

Log below.

No User exists for @gmail.com
Invalid parameter(s)
Attaches a user session to a remote desktop session.

TSCON {sessionid | sessionname} [/dest:sessionname]
[/password:pw] [/v]

sessionid The ID of the session.
sessionname The name of the session.
/DEST:sessionname Connect the session to destination sessionname.
/PASSWORD:pw Password of user owning identified session.
/V Displays information about the actions performed.

I don't have a way to test your scenario, but I suggest you try surrounding the username part of the script with single or double quotes.
jeliot Dec 13, 2017 @ 6:12pm 
Running Windows 10 here. When I run this script, it does make my computer "Ready" for streaming to Steam Link. However, the display on Steam Link is very buggy (sometimes flickers, sometimes forced to a low res, sometimes blank screen, sometimes, freezes) and basically is just as unusable as if the PC were locked.
`digitaL.braVo Dec 14, 2017 @ 12:17am 
Originally posted by jeliot:
Running Windows 10 here. When I run this script, it does make my computer "Ready" for streaming to Steam Link. However, the display on Steam Link is very buggy (sometimes flickers, sometimes forced to a low res, sometimes blank screen, sometimes, freezes) and basically is just as unusable as if the PC were locked.
I'm assuming you can unlock the computer normally and not experience this? My guess would be some power saving feature keeping your GPU at less-than-performance mode.

Just a theory to track down is all?
Is there a way that my wife can play my steam games on HER COMPUTER without taking over my computer at the same time? Thanks.
`digitaL.braVo Jan 2, 2018 @ 2:00pm 
Originally posted by dragonzord.21:
Is there a way that my wife can play my steam games on HER COMPUTER without taking over my computer at the same time? Thanks.
You can share your library but it's very poorly implemented. She cannot play any of your games if you're playing any of them. Not even if they're the same game.

I accomplished thisb y logging into my wife's computer under my account and then you can share the steam library to another account on that computer.

But we found that if I'm playing *anything* she cannot use any of the games from my library.
mmilitia Feb 18, 2018 @ 5:28pm 
Originally posted by amorpheous:
Originally posted by mmilitia:
Hi,

This solution used to work flawlessly before I upgraded to Microsoft 10 Creators update a week ago. Any idea what could be wrong? Log file says the following:

Could not connect sessionID 1 to sessionname console, Error code 7045
Error [7045]:The requested session access is denied.

I am the administrator to the computer, but have two accounts. 1 Standard and 1 admin. I know the admin password and have the shortcut requiring administrative permissions. It takes password perfectly fine, but throws up that error message.

Tested on the actual administrator account as well and changed the username in the script you provided. No go either.

Is tscon just broken? Anyone else running into any issues with this on Windows 10 Creators?


I've also upgraded to Creator's Update, but I don't have that issue. Did you change the script in any way?


Nope. I didn't change the script in anyway. After the upgrade it just stopped working for me. Unfortunately, it still is not working on Windows 10 1709(2 versions highter from last post?). Not sure what happened. I get this error message:

Could not connect sessionID 1 to sessionname console, Error code 1326
Error [1326]:The user name or password is incorrect.

Password\username is def not incorrect. I wouldn't be able to get past the password prompt if it was. Once I enter password in, I see the .cmd run in the black prompt, but no RDP disconnection occurs afterwards.

Last edited by mmilitia; Feb 18, 2018 @ 5:32pm
amorpheous Feb 21, 2018 @ 7:29am 
Originally posted by icedawg:
Originally posted by amorpheous:


I've also upgraded to Creator's Update, but I don't have that issue. Did you change the script in any way?


Nope. I didn't change the script in anyway. After the upgrade it just stopped working for me. Unfortunately, it still is not working on Windows 10 1709(2 versions highter from last post?). Not sure what happened. I get this error message:

Could not connect sessionID 1 to sessionname console, Error code 1326
Error [1326]:The user name or password is incorrect.

Password\username is def not incorrect. I wouldn't be able to get past the password prompt if it was. Once I enter password in, I see the .cmd run in the black prompt, but no RDP disconnection occurs afterwards.

If you run this command in a PowerShell prompt, what does it output?

quser $env:USERNAME
Di Jiensai Feb 28, 2018 @ 8:30am 
Originally posted by amorpheous:
Originally posted by icedawg:


Nope. I didn't change the script in anyway. After the upgrade it just stopped working for me. Unfortunately, it still is not working on Windows 10 1709(2 versions highter from last post?). Not sure what happened. I get this error message:

Could not connect sessionID 1 to sessionname console, Error code 1326
Error [1326]:The user name or password is incorrect.

Password\username is def not incorrect. I wouldn't be able to get past the password prompt if it was. Once I enter password in, I see the .cmd run in the black prompt, but no RDP disconnection occurs afterwards.

If you run this command in a PowerShell prompt, what does it output?

quser $env:USERNAME

I had the same problem, and needed to change the [2] to [1] in the subcommand to get the session id.

did they change the fields maybe?
Danaa Dec 26, 2019 @ 11:36am 
I've been looking for kind of this solution but this is EXACTLY what I looking for
U ARE INSANE Thank you very very much
Neo Vg Jan 5, 2023 @ 8:11am 
Thank you so much for this thread! 🙏 This was almost the solution is was looking for, and could easily be adapted to my needs.

My use case is a little bit different, as I wanted to be able to wake up and unlock my Gaming PC using the Shortcuts app on my iPhone, which can be controlled via Siri ("Hey Siri, wake up the PC!").

The shortcut connects via SSH to my home server and executes a bash script, which via WOL wakes up the PC. Therefor manually opening an RDP connection to run the unlock-script was out of question; instead the bash script should trigger the unlock-script via SSH connection to the Windows PC (I already had an SSH server installed to be able to remotely put the PC into sleep mode via another Siri Shortcut).

The problem was, that without opening an RDP connection first, quser $env:USERNAME shows an already active session with the name "console", and executing tscon $sessionid /dest:console throws error 7045:

PS C:\Users\neo> quser $env:USERNAME USERNAME SESSIONNAME ID STATE IDLE TIME LOGON TIME neo console 1 Aktiv . 05.01.2023 14:45 PS C:\Users\neo> tscon 1 /dest:console Could not connect sessionID 1 to sessionname console, Error code 7045 Error [7045]: The requested session access is denied.

This however can be easily fixed by running tsdiscon $sessionid before running tscon $sessionid /dest:console.

PS C:\Users\neo> quser $env:USERNAME USERNAME SESSIONNAME ID STATE IDLE TIME LOGON TIME neo console 1 Active . 05.01.2023 14:45 PS C:\Users\neo> tsdiscon console PS C:\Users\neo> quser $env:USERNAME USERNAME SESSIONNAME ID STATE IDLE TIME LOGON TIME neo 1 Disc . 05.01.2023 14:45 PS C:\Users\neo> tscon 1 /dest:console

There is one catch though when doing this in the script:

When ((quser $env:USERNAME | select -Skip 1) -split '\s+')[2] is executed before tsdiscon, it returns the session name ("console"). So simply running tsdiscon $sessionid; tscon $sessionid /dest:console would not work, as the disconnected session does not have a name anymore, so the ID has to be used instead (see code block above).

This however can be easily fixed by executing ((quser $env:USERNAME | select -Skip 1) -split '\s+')[2] again after running tsdiscon, which then returns the session ID instead the name. The complete script therefor is:

powershell -NoProfile -ExecutionPolicy unrestricted -Command "$sessionid=((quser $env:USERNAME | select -Skip 1) -split '\s+')[2]; tsdiscon $sessionid; $sessionid=((quser $env:USERNAME | select -Skip 1) -split '\s+')[2]; tscon $sessionid /dest:console"

The bash script on the server looks something like this:

PC_MAC="..." PC_IP="..." if ! ping -c 1 -t 1 $PC_IP &>/dev/null; then echo "PC is not awake, waking up..." /opt/homebrew/bin/wakeonlan $PC_MAC echo "Waiting for PC to wake up..." sleep 15 echo "Logging in..." ssh $PC_IP "C:\Users\neo\unlock.bat" fi

The sleep is necessary, as running the unlock-script to soon after wake will fail. On my system, 10 seconds isn't quite enough, but 15 seems to work reliably.

PS: The bash script also uses ADB (Android Debugging Bridge) to wake up the Philips TV the PC is connected to, and to set the correct HDMI input. I tried to do this via CEC, but unlike the Raspberry Pi, almost no PC graphics card seems to support this. :-/
Last edited by Neo Vg; Jan 5, 2023 @ 8:12am
amorpheous Jan 5, 2023 @ 8:27am 
Thanks for your contribution Neo Vg! That's great work. I'm sure it'll be useful to others. I'm likely to use it myself in the future once I've got my own server set up.
Dr. Friendly Dec 24, 2023 @ 1:04pm 
It has been about a year since I tried this but I get terrible connection using this method now? Using remote desktop is way better by comparison while both machines have great connection. Any solutions?
amorpheous Jan 2, 2024 @ 4:26am 
Originally posted by Dr. Friendly:
It has been about a year since I tried this but I get terrible connection using this method now? Using remote desktop is way better by comparison while both machines have great connection. Any solutions?


Hey there,

Apologies for the late reply; I've been away for a bit.

I'm not sure what you mean when you say you get a terrible connection using this method. This guide is only for unlocking a Windows machine remotely so that you can use Steam Remote Play. There should be no impact on connection quality.

That said, could you elaborate a bit on your setup and maybe someone can help? You might get more visibility if you post your issue as a new thread too.

Cheers,

Morphy
< >
Showing 61-75 of 77 comments
Per page: 1530 50

Date Posted: May 16, 2015 @ 6:58am
Posts: 77