我创建了一个vbs脚本来启动程序并输入登录凭据。当我通过单击它运行脚本时,它可以完美地运行,但是当通过调度程序启动时,它无法按预期工作。脚本如下:
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~"
当通过调度程序启动时,我看到Bloomberg在任务栏中打开,但窗口永远不会被激活,也不会放入凭据。任何想法都是为什么它不起作用?