+ Post New Thread
Results 1 to 11 of 11
Scripts Thread, Startup Scripts Takes Ages To Load When No Connected in Coding and Web Development; ...
  1. #1

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,956
    Thank Post
    886
    Thanked 1,700 Times in 1,477 Posts
    Blog Entries
    12
    Rep Power
    448

    Startup Scripts Takes Ages to Load When Not Connected to The Network

    Hi

    When anyone uses a laptop that is not connected the network it takes ages to get past the “running startup scripts”. Obviously its not loading them because the machine isn’t connected the network. What can I do to stop scripts running when the machine isn’t on the network? Or could I make a timeout on the computer to make it giveup after x number of seconds failing loading the script?

    Thanks for the advice.
    Last edited by FN-GM; 16th February 2008 at 12:05 PM.

  2. #2

    mattx's Avatar
    Join Date
    Jan 2007
    Posts
    9,240
    Thank Post
    1,058
    Thanked 1,068 Times in 625 Posts
    Rep Power
    740
    Use a conditional statement to check for network settings in the script before it runs:

    Code:
    If network connection exsists run script
    Else Exit
    Endif
    You could use the PCs IP address as the condition.....

  3. #3

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,956
    Thank Post
    886
    Thanked 1,700 Times in 1,477 Posts
    Blog Entries
    12
    Rep Power
    448
    Thanks again for your help.

    I am not a good scripter, still learning. How would i setup the rule? the laptop may be connected to a home network so it may detect a network connection still.

  4. #4

    mattx's Avatar
    Join Date
    Jan 2007
    Posts
    9,240
    Thank Post
    1,058
    Thanked 1,068 Times in 625 Posts
    Rep Power
    740
    Quote Originally Posted by FN-Greatermanchester View Post
    Thanks again for your help.

    I am not a good scripter, still learning. How would i setup the rule? the laptop may be connected to a home network so it may detect a network connection still.
    In that case then you need to set some rules or a flag. Get the script to check for an IP address, if it has one, get it to check for something YOU know it would be able to ping or read a file on the school network. If it pings ok or it can read the file , then the script runs, if the ping returns a null value or the file does not exist it does not run.
    As you know I tend to favour AutoIT in my scripts so I would use the @IPAddress1 macro or FileExists function.

    As for not being a good scripter, nor am I, never have, never will be - I just keep plugging away at it.

    Just checking up on the ping function on AutoIT and they provide a very good example:

    Code:
    $var = Ping("www.AutoItScript.com",250)
    If $var Then; also possible:  If @error = 0 Then ...
        Msgbox(0,"Status","Online, roundtrip was:" & $var)
    Else
        Msgbox(0,"Status","An error occured with number: " & @error)
    EndIf
    Last edited by mattx; 16th February 2008 at 01:17 PM.

  5. #5

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,956
    Thank Post
    886
    Thanked 1,700 Times in 1,477 Posts
    Blog Entries
    12
    Rep Power
    448
    $var = Ping("www.AutoItScript.com",250)
    If $var Then; also possible: If @error = 0 Then ...
    Msgbox(0,"Status","Online, roundtrip was:" & $var)
    Else
    Msgbox(0,"Status","An error occured with number: " & @error)
    EndIf
    Right so i would change that web address to an ip address of a server on the network? Then put that directly at the top of my VBS Script?

    Thanks alot

  6. #6

    mattx's Avatar
    Join Date
    Jan 2007
    Posts
    9,240
    Thank Post
    1,058
    Thanked 1,068 Times in 625 Posts
    Rep Power
    740
    I don't script in VBS so you would have to find the relevant function...

  7. #7

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,956
    Thank Post
    886
    Thanked 1,700 Times in 1,477 Posts
    Blog Entries
    12
    Rep Power
    448
    Im totally lost by this, thanks anyway.

    z

  8. #8

    Join Date
    Jan 2006
    Location
    Surburbia
    Posts
    2,178
    Thank Post
    74
    Thanked 307 Times in 243 Posts
    Rep Power
    115
    WMI will get you what you want, but it's probably easier to do something like the folllowing which simply looks at what ipconfig says. It's JS coz I don't VBS either, but there will be a very similar VBS equivalent:

    Code:
    var s = RunCommand("ipconfig");
    if (s.indexOf("10.10.10.254")>0) 
    {//Found work's default gateway - we're at work
         //do something
    }
    
    function RunCommand(cmdLine)
    {
        var so = new ActiveXObject("WScript.Shell");
        var outStream = so.Exec(cmdLine);
        return outStream.StdOut.ReadAll();
    }

  9. #9

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,956
    Thank Post
    886
    Thanked 1,700 Times in 1,477 Posts
    Blog Entries
    12
    Rep Power
    448
    So what do i do with that code please?

  10. #10


    Join Date
    Jul 2007
    Location
    Rural heck
    Posts
    2,662
    Thank Post
    120
    Thanked 434 Times in 353 Posts
    Rep Power
    126
    The chances are if you've got no network connection the script isn't even running so adding a line to detect the presence of a network will be pointless.

    I think there's a setting in group policy to adjust the length of the time out.

  11. #11

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,956
    Thank Post
    886
    Thanked 1,700 Times in 1,477 Posts
    Blog Entries
    12
    Rep Power
    448
    Very true, i will look for it

SHARE:
+ Post New Thread

Similar Threads

  1. Network taking ages to load
    By tscnmuk in forum Windows
    Replies: 5
    Last Post: 27th June 2008, 10:59 AM
  2. Startup scripts
    By djones in forum Windows
    Replies: 10
    Last Post: 27th February 2008, 12:18 AM
  3. Replies: 1
    Last Post: 6th February 2008, 09:37 AM
  4. VBS File takes long time to load 1st time?
    By Samson in forum Scripts
    Replies: 3
    Last Post: 4th September 2007, 07:40 AM
  5. Computer Startup Scripts
    By Spot in forum Windows
    Replies: 18
    Last Post: 16th November 2005, 11:06 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •