0

I made a vbs script to launch a program and to put in the login credentials. When i run the script by clicking it works perfect, but when launched trough the scheduler it does not work as desired. The script is as follows:

Dim objShell
Set objShell = WScript.CreateObject( "WScript.Shell" )
objShell.Exec("C:\blp\Wintrv\WINTRV.EXE")
Set objShell = Nothing
WScript.Sleep 5000

set WshShell = WScript.CreateObject("WScript.Shell")
WScript.Sleep 1000
WshShell.AppActivate "1-BLOOMBERG"
WScript.Sleep 1000
WshShell.SendKeys "{ESCAPE}"
WScript.Sleep 1000
WshShell.SendKeys "login~"
WScript.Sleep 1000
WshShell.SendKeys "username   "  'do not remove spaces after username
WScript.Sleep 1000
WshShell.SendKeys "password~"

When launched via the scheduler i see that Bloomberg opens in the task bar, but the window is never activated nor the credentials are put in. Any idea's why it does not work?

  • 2
    You can't set the foreground window unless you have it. There is no windows in the foreground for TS. So TS, and thus your script, can't set the foreground window. –  Oct 17 '16 at 17:07
  • Sorry for the rather late reply. What is exactly the definition of a foreground window? And is there a way to set the foreground for the task scheduler, or is this not possible? – user7031491 Oct 31 '16 at 13:49
  • Foreground window is the window that is on top of all other windows. If it can accept keyboard input it is where the focus is. –  Oct 31 '16 at 21:01
  • I know this is very old post however, for sake of others benefit, you may follow the post here: https://stackoverflow.com/questions/72642190/sendkeys-to-bloomberg-panel-python/74476326#74476326 – Kiran Jain Nov 17 '22 at 14:15

0 Answers0