Discussion Locked

VBScript NOT running scheduled task W2K

0 helpful
5 replies
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

5 replies

by jay eckles

I had a similar problem when trying to run a regression testing script in Rational Robot (which uses a scripting language very similar to VBScript). The only solution we ever came up with was to remove the "sleep" timeout, turn off the monitor, andput the computer in a secure room.

Hope you find something more elegant. Good luck.

Jay Eckles
www.jayeckles.com

by glen_mcleod

Sorry, it can't be done. VBS needs a user session to be open and active because it runs in the security context of the logged on user.

On the other hand, you could easily convert your VBS code to VB (some minor syntax changes might be necessary), compile it, then schedule the resulting .exe to run unattended. This will work, as I had the same problem and that is how I solved it.

Glen

This discussion is closed to new replies.