Hi all,

I am trying to schedule a Task that will run a vb script to open a browser, send some keys, and finally close the browser. The task starts, but seems to hang. The task is created as follows:

schtasks.exe /Create /RU "SYSTEM" /SC "DAILY" /MO "1" /ST "23:00" /TN "Open Browser" /TR "C:\somefolder\somescript.vbs"

The script looks like:

Set oShell = WScript.CreateObject("WScript.Shell")

oShell.Exec "iexplore http://localhost/mylocalsite"

WScript.Sleep 10000

oShell.SendKeys "uname"
oShell.SendKeys "{TAB}upassword"
oShell.SendKeys "{ENTER}"

WScript.Sleep 20000

'Close browser'
oShell.SendKeys "^w"

Also, adding c:\program files\internet explorer\ to my path variable allows me to execute iexplore as a command.

Edited by RudyM: Added detail for clarification. Uncommented.

2 Years
Discussion Span
Last Post by ankitjaswal5044

@rproffitt, thanks for the link, but I'm not sure how I could use it in the VBScript. As for the use of "SYSTEM" in a user context, I've also tried using local accounts and have not succeeded.

Also, the script runs without issue when executed manually.


Think context. Use your account instead of system. I'm sure this has been kicked around many times, since IE is in some non-gui instance, you may find sending keystrokes to fail.

Maybe your goal is to log into a site daily or something. Maybe there are other ways like telnet and other scripts.


This is related to another problem that seems to solve itself when I log in and view a web-page and finally just close it. I will look into other alternatives, thanks.


I retried this in a batch file and it worked.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.