Jump to content

Startup Scripts Takes Ages To Load When No Connected


Recommended Posts

Posted (edited)

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.

Edited by FN-Greatermanchester
Posted

Use a conditional statement to check for network settings in the script before it runs:

 

If network connection exsists run script
Else Exit
Endif

 

You could use the PCs IP address as the condition.....

Posted

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.

Posted (edited)
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:

 

$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

Edited by mattx
Posted
$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

Posted

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:

 

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();
}

Posted

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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...