[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 406
  • Last Modified:

VBS Script closes too fast

Hi guys, i have a small script that opens a web site, clicks the login button and then closes the web site. Although this works, it closes too fast for the web site to render username, etc and log the user into the site. What is the code to adjust this so it has a few more seconds after the button is clicked to render then page, then close?

I'd also like to have this script run as a login script for specific OU's, im assuming it should be fine.

Thanks!
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Visible = True
objIE.Navigate "http://susaspweb"
While objIE.Busy = True And objIE.ReadyState <> 4
   WScript.Sleep 100
objIE.Document.All.btnLogin.Click()
Wend
objIE.Quit

Open in new window

0
susnewyork
Asked:
susnewyork
  • 2
1 Solution
 
omgangCommented:
Dim intInterval    'in miliseconds

intInterval = 1000    'one second

WScript.Sleep intInterval

OM Gang
0
 
Bill PrewCommented:
As omgang mentions (so points to him), you already are using the sleep inside the loop, just add another delay in after the loop ends, beforte the quit, as in (2 second delay in my example below, adjust as needed):

Set objIE = CreateObject("InternetExplorer.Application")
objIE.Visible = True
objIE.Navigate "http://susaspweb"
While objIE.Busy = True And objIE.ReadyState <> 4
   WScript.Sleep 100
   objIE.Document.All.btnLogin.Click()
Wend
WScript.Sleep 2000
objIE.Quit

Open in new window

~bp
0
 
omgangCommented:
Hah!  now that's funny.  I read the Q but didn't actually read through the posted code so didn't notice the Sleep method was already being employed.
OM Gang
0
 
susnewyorkAuthor Commented:
Hey Thanks OM Gang!!

I just didnt think that it was that simple? i did try that before on a test machine that i realized had IE issues. When i tested just now on a different machine, it did exactly what it should have.

Thanks again!
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now