Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script taking forever to execute

Status
Not open for further replies.

mark01

Technical User
Jan 17, 2001
600
US
I have replaced my batch file login scripts with vbscript. But now it takes forever for the script to execute. It will wait until everything is loaded, waited a good 10-15 seconds, then execute. It will do this on all machines (XP & 98). We are even on a 100mb connection. So users will try & access shortcuts to drives that are not mapped yet, and will complain the it isn't working.

How can I speed things up, or at least wait until the script is done executing before windows loads...

Thanks.
 
I have it defining 8 variables at the start, then it opens an ie pop-up box. This is where it takes forever, to load the popup box.
 
On Error Resume Next
'Setting Variables
Dim WshNetwork, asdPath, User
Dim strMappedDrives, strStatus
Dim IE
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
Dim FSO
Set FSO = CreateObject("Scripting.FileSystemObject")

Call CreateIE()
Sub CreateIE()
On Error Resume Next
set ie = createObject ("internetExplorer.Application")
with ie
.navigate "\\domain1\test\script.htm"
End With
Do while ie.busy
wscript.sleep 100
Loop
End Sub
 
I commented the sleep command out, and still gets the same result.

When I run this script directly, it runs fine, but when I run it as a login script, it takes a long time to load.
 
i woould say the idea of loading internet explorer to display html is fundamentally flawed when dealing with a logon script. by its name you should be running a script which shouldnt really need a gui and if it does it should only be simple.

you can run logon scripts interactively or not?? i am not sure, ie windows will continue to load only after the script has finished.

or are you calling the vbscript from a batch file which isnt waiting for this thread to finish? so windows thinks the logon script has finished due to the batch file ending?

or does the vbscript terminate after calling the sub and not worry about the ie object??

anyway this isnt strictly what you asked but i wouldnt load IE via a logon script. what would happen if IE was messed up on a machine? would it never logon? would it cause the machine to blue screen if IE was causing that sort of issue etc etc
 
Hello mark01,

How do you know it takes forever? Are you seeing its presence in the process monitor or task manager?

[1] You have to have more control if you use onerror. If you do not have any idea where it might fail, do not use it and let the script fails at runtime.
[2] You have to make ie visible just (in case don't know).
Code:
Sub CreateIE()
  'On Error Resume Next
  set ie = createObject ("internetExplorer.Application")
  ie.visible=true
  with ie
     .navigate "\\domain1\test\script.htm"
  End With
  Do while ie.busy
  wscript.sleep 100
  Loop
  set ie=nothing
End Sub
regards - tsuji
 
Awesome, that worked pretty good.

Only thing is that the ie opens in a full screen for a split second, then goes down to the right size. I have code that I didn't post that set's the ie box to the right size.

But I can't complain, speed is more important than the looks.
Thanks...
 
I know this is a thread revival but may help future people who find it in searches.

If you are using vbscript as a logon script you should use the group policy editor of the local machine or the domain policy and enable the following setting.
Computer Configuration->Admin Templates->System->Scripts->Run Logon Scripts Synchronously.
This will ensure the logon scripts are finished before windows explorer loads

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top