Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am writing some script that automatically executes during startup of computer (XP), the script is actually mapping a network drive to windows. The problem I have is that the DHCP in the network is not responding fast enough and that the script executes before the system got IP. So an error would occur.

Before putting the system under AD, my solution is to make the script "Sleep" for about 30 seconds and of course this is just an ad-hoc solution. Any related script that can do such job?

share|improve this question
up vote 1 down vote accepted

A common (and somewhat kludgy) way to solve this problem is to write a function that "waits for the network" by essentially trying to ping a host until it succeeds. You can optionally include a timeout value where the script will eventually give up. I have a JScript based version of this function if you'd like me to post it.

I would think a more elegant way to do this would be to use WMI to query the status of the network adapter in a loop until you've got a valid IP address. I don't have an example of doing this though.

Here are some other things to think about when choosing a solution. It will be up to you to determine how robust you care to make it.

  • Just because DHCP has returned a valid IP doesn't mean you can connect to your fileserver
  • Just because you can ping your fileserver doesn't mean mapping a drive will always work
share|improve this answer
good points, I think I should start a new question to refine my problem. thx – xandy Sep 25 '09 at 7:28

I can't tell for sure from the question, but if the PC is joined to a domain, you can apply the policy:

Computer Configuration\Administrative Templates\System\Logon\

Always wait for the network at computer startup and logon

via GPO to force the PC to wait for the network before giving a logon prompt. If the PC isn't a domain member, you could set the same policy using GPEdit or maybe via a reghack.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.