Discussion Locked

VBS NOT execute in scheduled task W2K

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi All,
Please help! I scheduled a task to run every night by executing a VBScript file. The purpose is to post to the url or servlet to create the html file. The VBScript opens browser, invokes url, wait while html file is creating, and close the browser. The test ran fine when the computer is not locked (CTRL+ALT+DEL,W). If the computer is locked, the VBScript seems NOT to executes. I log every single line of executed code. It's executed every line of code but it's not open the browser go to the url. Attached is a snipped code, please help.

Dim WshShell, generateURL, siteURL
generateURL = "http://localhost:8080/job/generateColor.html"
siteURL = "http://localhost:8080/test/index.html"
Set WshShell = WScript.CreateObject("WScript.Shell")

'OPEN BROWSER
WshShell.Run "IEXPLORE"
'sleep time (no action)
WScript.Sleep(100)
'no address in the address bar
WshShell.AppActivate "about:blank"
WScript.Sleep(100)

' OPEN THE HTML FILE THROUGH BROWSER
'Enter the URL in the address bar
'open address bar - CTRL+O or ALT+F+O
WshShell.SendKeys("^o")
'enter the url
WshShell.SendKeys(generateURL)
'enter or return key
WshShell.SendKeys("~")

' SLEEP, NO ACTION
'Allow browser time to load html
WScript.Sleep(5000)
WshShell.AppActivate "focus"

' OPEN THE HTML FILE THROUGH BROWSER
'Enter the url in the address bar
WshShell.SendKeys("^o")
WshShell.SendKeys(siteURL)
WshShell.SendKeys("~")

'SLEEP, NO ACTION
'Allow browser time to load html
WScript.Sleep(5000)
WshShell.AppActivate "EFB"

'CLOSE BROWSER
'Close browser ALT+F4
WshShell.SendKeys("%{F4}")

Set WshShell = Nothing

1 reply

by beermonster

Hi,
You've answered your own question. utils like scriptit and the vbsendkeys method will only work if the active window is actually displayed on the screen (IE no screensaver or locked screen). This is because those utils are supposed to mimican actual user interaction, and so are based around what would be visible on the screen at the time....

This discussion is closed to new replies.