Log into Windows 10 using a script

1.6k views Asked by At

Here's some background:

I'm currently working on a project where I use the Windows Task Scheduler (triggered by computer waking from sleep) to run a Python script that turns on my webcam and runs a facial recognition scan. If the facial scan returns a match, then I want to run a script that logs me into my computer. Currently, my Python script that I described works as intended-I can see that the webcam turns on and is correctly triggered, and the facial recognition runs perfectly. I'm just stuck on how to implement this login script.

Some things I've tried:

  • A batch script that sends keyboard input (my password).

     set WshShell = CreateObject("WScript.Shell")
     WScript.sleep 5000
     WshShell.SendKeys "{ENTER}"
     WScript.sleep 1000
     WshShell.SendKeys "password"
     WScript.sleep 1000
     WshShell.SendKeys "{ENTER}"
    

    This script wasn't actually able to send the keyboard inputs to the login field for some reason.

  • A python script using Pyautogui to send keystrokes to the lock screen. Also did not work for some reason

  • A script that edits the registry keys to enable AutoLogon, and then disable AutoLogon right after. This script didn't work because I wasn't able to run it with elevated Admin permissions.

    reg ADD "HKLM\Software\microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultUserName /d <user> /f
    reg ADD "HKLM\Software\microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultPassword /d <password> /f
    reg ADD "HKLM\Software\microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon /d 1 /f
    reg DELETE "HKLM\Software\microsoft\Windows NT\CurrentVersion\Winlogon" /v CachedLogonsCount /f 
    

The attempts I've made seem like silly solutions to something that I feel like should have a more straightforward approach. Does anyone have any other ideas or leads for me to look into? If any of those 3 things I've tried could still work, I'd also like some feedback on that.

0

There are 0 answers