Windows – How to unlock Windows 7 screen using script

scriptSecuritywindowswindows 7

I am wondering if there is any way to unlock Windows 7 screen lock using a script. I have administrator permissions on this machine.

I know this question have been asked before without a solution, but I hope someone has come up with answer since.
I would like a script or program to be run, when certain conditions are met, which in result unlocks the screen.

Alternatively is there any possibility to reliably disable communication with a computer with keyboard and mouse strokes while it displays a black screen?
By that I mean: can I use low level programming to create screen lock which I can control. I hope it won't be necessary, as I got very promising answer.

Best Answer

How to unlock Windows 7 screen using script

You can define and save an RDP file with all needed options, and point it to the machine to make the connection. You will set the configuration to save the credential and then enter and save the credential values. Now each time you double-click the RDP icon (from that same account and machine you created it on), it should automatically load the desktop for the user account credential you saved without needing to enter the password.

Configure RDP Icon

Press the Windows Flag Key one time and then immediately start to type in "MSTSC" or "Remote Desktop Connection" to find the Remote Desktop Connection app to launch, and then follow the below instructions for further steps.

enter image description here

Configure a Remote Desktop Connection and then Save to an RDP File

  1. Type in the Server Name or IP address in the Computer field (see below screen shot for #1 - #5)
  2. Type in the MachineName\Username in the Username field

    • Be sure to use the machine name backslash username in that format but you can replace the machine name with the IP address of the machine you are connecting to with the RDP file if you need to and know the IP address (assuming the IP address doesn't change)
  3. Be sure to select\check the Allow me to save credentials option

  4. Press the Save As option and tell it what to name the file and where to save it to so you can have the batch script launch it in later steps
  5. Press the Connect option and then follow the instructions below the screen shot below for what to do next to save the credential, and the rest

    enter image description here

  6. Type in the password of the account making the remote connection in the Password field (screen shot below)

  7. Check or select the Remember by credentials option and then press OK (screen shot below)
    • This step will need to be done only once per each logged in account that will need to open the connection and this will also be per machine that account logs into which it needs to perform this operation.
  8. Now simply double-click the RDP icon that you saved in the #4 step and confirm the RDP session opens without asking for password
  9. Now follow the instructions below for creating a batch script that will launch the RDP file to open the Remote Desktop Connection to the machine without needing to enter a password for the connection.

    enter image description here

For the last step you will create a batch script that will launch that RDP file you just defined and saved to open the connection without prompting for password. Be sure the full explicit path is what you point the script to for where you saved the RDP file in step #4 above where the script example has "C:\Users\User\Desktop\<ServerName or IP Address>.rdp".

Batch Script using MSTSC

@ECHO ON
MSTSC "C:\Users\User\Desktop\<ServerName or IP Address>.rdp"
GOTO EOF
Related Question