Jacob Dorsey
Jacob Dorsey

Reputation: 197

Get a VBScript to run properly while my computer is locked

I put a pause into the code to break it down and make sure it is doing what it is supposed to do. Its not.

The Check1.msl will spit out a file named check.rpt. When I run it manually and the batch file pauses - check.rpt is there. I schedule the task and lock my computer. When I log back in, the msl program is open and the cmd prompt is sitting at pause but there is NO check.rpt file.

Here is what I have at the beginning:

@ECHO OFF
PUSHD "%~dp0"

ECHO CD is now %CD%

PING 1.1.1.1 -w 2000 -n 1
echo starting the check1 msl file
DIR Check1.msl
Start Check1.msl

PING 1.1.1.1 -w 2000 -n 1
echo starting the password injector file
WScript //B passwordinjector.vbs

pause
POPD
exit

Here is the VBScript called passwordinjector.vbs

set wshshell = wscript.CreateObject("wscript.shell")
wshshell.AppActivate "User Login"
WshShell.SendKeys "Username"
WshShell.SendKeys "{tab}Password"
WshShell.SendKeys "{tab}{enter}"

I've tried cscript passwordinjector.vbs to no avail.

EDIT:

Researching (and common sense) I figured out that you can't .SendKeys while the computer is locked. I need an alternative way to pass the log in information to the program. How do I pass a username and password to a prompt from a program?

Upvotes: 0

Views: 644

Answers (1)

Ansgar Wiechers
Ansgar Wiechers

Reputation: 200273

How you can pass login information to a program depends on how that particular program expects login information. Unless you're able to present credentials in a commandline or something similar (like a HTTP POST request for instance) this can't be done with VBScript I'm afraid.

You may want to consider switching to something that is more suitable for GUI automation, like AutoIt.

Upvotes: 1

Related Questions