Windows – Vbscript for autologin

scriptvbscriptwindowswindows 10windows-10-v1607

I have retrieved a VBscript that may have worked in other scenarios to auto login windows ran by a task scheduler when windows is logged off by automating the logon process like a normal user would do on windows 10.
IE: user arrives to a computer, presses enter for the login screen to appear, types in username, presses tab and enters password and clicks enter and the user logs in.

here is the script :

set wshShell = CreateObject("WSCript.shell")

wshShell.sendkeys "{ENTER}"

wscript.sleep 5000

wshShell.sendkeys "Username"

wscript.sleep 5000

wshShell.sendkeys "{Tab}"

wscript.sleep 5000

wshShell.sendkeys "Password"

wscript.sleep 5000

wshShell.sendkeys "{ENTER}"

WScript.Quit

now the code works find if i run it from a logged on user in windows, it presses enter types the username presses tab type password and presses enter, but when i create a task to run, nothing happens and if i look at the history of the task it says that the process ran successfully which means there was no errors.

I have tried to convert it to EXE still same results any help or fix would be appreciated,

Thank you.

Best Answer

I cannot add comments so maybe this will answer your question or help. Are you using a .bat file to execute your script in the scheduled task? You would create a file named something like "Start.bat". It would just be a single line like this:

start wscript.exe "C:/Users/MyName/Desktop/PopUp.vbs"

When setting up this task, the file name would go here (see pic) - which I'm sure you already know performing these options:

Name > When computer starts > Start a program > Program script (browse to the .bat) > Finish

Browse file for scheduled task

Related Question