Adding a delay to drive connections

On a Windows XP Pro laptop that has remote access to an organization's network, the mapped drives try to connect to the network before the wireless connection is established and they error out as disconnected and we have to reconnect them after the network connection is established.  Is there a way in the registry or another means to add some kind of delay so that the drives will attempt to connect say 60 seconds later then they are now or can someone give an example of a loginscript.bat that can be placed in startup to cause a delay of the mapped drives?  Any assistance offered would be greatly appreciated.
regsampAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Steve KnightIT ConsultancyCommented:
You could use PING command to enter a delay, e.g.

ping 1.1.1.1 -w 60000 -n 1

would give a 60 second delay as long as host 1.1.1.1 times out.  If a router reports not reachable then try a real host the other side of the wireless LAN because then it will wait 60 secs if not connected to wireless or carry on straight away if you are.

hth

Steve
Steve KnightIT ConsultancyCommented:
Or you could do something like this:

REM wait 60 secs if no ping response from server
ping server -w 60000 -n 1
:retry

net use x: \\server\share

rem if net use did not work wait another 30 secs then try again

if errorlevel 0 goto next
net use x: \\server\share

:next
net use y: \\otherserver\othershares

Steve
regsampAuthor Commented:
Is there a way to edit the script so that it is not pinging and just a straight delay in the batch file because this laptop is on a network that is behind a firewall, behind a router, going to remote network, etc, etc.?  For example, a straight batch file that just says something like mapped drive net use z(or which ever drive letter is open): \\servername\sharename wait 60 seconds.
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

BLipmanCommented:
write a batch file with sleep.exe

This command will put a pause in for the seconds you specify.  
regsampAuthor Commented:
I do not easy access to sleep.exe and should be another way to specify a delay in seconds in a straight batch file for mapped drives.  
rsivanandanCommented:
Edit the Group Policy for the Domain or the Local Policy on the machine as below;

Computer Configuration->Admin Templates->System->Logon->Always wait for the network at computer start and logon

This will make sure that the computer makes sure to wait till the network to come active before it attempts to map the drives and you'll be okay.

If you do it AD Group policy, it will be effective for all (Good for you, less calls for support saying I don't have my H: drive :-)) If you do it only for those people with remote access, that'll be fine too. Just make sure the domain policy doesn't override it.

Cheers,
Rajesh
regsampAuthor Commented:
"Edit the Group Policy for the Domain or the Local Policy on the machine as below;
Computer Configuration->Admin Templates->System->Logon->Always wait for the network at computer start and logon
This will make sure that the computer makes sure to wait till the network to come active before it attempts to map the drives and you'll be okay."  We had the remote user do this and they stated it worked for only one reboot and it no longer works.  


rsivanandanCommented:
Do you have a Domain Policy? Try to set it onto the domain policy because it will override the local policy upon connection.

Cheers,
Rajesh
regsampAuthor Commented:
This computer is located at an employee's home and it is a spare laptop on their network.  They connect through a firewall, through a VPN tunnel to our firewall.  The group policies do not affect this computer.  A login script in batch format with net use x: \\server\share in a delay would be ideal.  
BLipmanCommented:
You can always download sleep.exe from the Internet and place the exe on your NETLOGON share or wherever the mapping runs from.  
rsivanandanCommented:
RegSamp,

  I'm not sure now on how you are running it now. The steps I assumed and should be is as below;

1. Create a logon script like;

net use Z: \\computerip\sharename /u:domain\username <password>
.
.
.

2. Place that file in the startup folder on that machine which is having problem.
3. Have the policy settings as I mentioned above on the local machine.

Then it will at any time, run this script only when the network connection is established.

To speedup things, use the server's ip instead of name or add the resolution in the 'hosts' file. Try this and post it here. Also what kind of VPN are you using?

Including the above mentioned sleep is also a good idea.

Cheers,
Rajesh

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
regsampAuthor Commented:
We do not have a netlogon share for remote users.  This user has a laptop that has wireless connectivity and when he turns on the machine, the mapped drives try to connect before the actual network wireless connection is established (going through a firewall, router, ISP, etc) with the credentials saved in Managed Passwords in Windows and because the drives cannot connect because the network connection is not established, any network apps that are started will not run unitl the user goes into My Computer and connects each drive.  Now I do not have access to the machine to install sleep.exe and then try a few things and they have tried "Edit the Group Policy for the Domain or the Local Policy on the machine as below;
Computer Configuration->Admin Templates->System->Logon->Always wait for the network at computer start and logon" with no change after one reboot but if I can give him some kind of simple batch file which will cause a delay in the mapped drives trying to connect or even a registry setting that will cause a delay then that would be ideal.  
rsivanandanCommented:
That is what I mentioned above. Create the logon script (as above) and have 'em post it to the startup folder. The other setting in the policy is already done right? So you don't have to do anything more.

Cheers,
Rajesh
regsampAuthor Commented:
"To speedup things, use the server's ip instead of name or add the resolution in the 'hosts' file. Try this and post it here. Also what kind of VPN are you using?"  Which server IP or do you mean is ISP server and we use SonicWall for VPN tunnels.  
regsampAuthor Commented:
rsivanandan, should we use net use z: /delete before net use Z: \\computerip\sharename /u:domain\username <password> in the batch file?  
IsigowCommented:
Best way is a logon script in the user's startup folder or as a file on their desktop (requires win2k or above)
group policy can tend to fail if the user is heavily delayed on authentication
WScript.Sleep is in mili-seconds
just copy and name file anything.VBS
granted you could also take it a step further and setup a looping ping that tries every 5 seconds and once it gets a response it connects the drives, times out over certain period..etc...but this one is nice and basic
========================
On Error Resume Next
Set objNetwork = CreateObject("WScript.Network")
Set WScript = CreateObject("WScript.Shell")
WScript.Sleep 60000
objNetwork.MapNetworkDrive "Z:", "\\server1\share$"
objNetwork.MapNetworkDrive "U:", "\\server1\share2"
regsampAuthor Commented:
Isiqow, I will try your script and substitute the drive letters for ours and the server and share names.  Can ip addresses be used instead of names and the rest is just copied exactly the same and called something.vbs, correct?  
rsivanandanCommented:
Either a normal batch file or the vb script. You can substitute ip addresses. By addresses I meant the Server Ip address where the shares are located.

Cheers,
Rajesh
IsigowCommented:
Raj has it right, IP's are fine.
Change drive letters, server name and share name and you should be ok. Just remember that if he is delayed logging into Active Directory or is relying on a cached policy the logon script will have to be executed on his local machine.

Isi
Steve KnightIT ConsultancyCommented:
Glad you are getting there.  Reason I suggested PING originally is because it is an easy built in way of doing a delay when you use the -w paramater, did you try it?

As you say GP doesn't effect this box I presume it is not a member of the domain and therefor never runs a logon script from the server, just locally.

I suggest you have a batch file on the laptop and delete the drive mapping first and set it as non persistent when you map it and use the commandline username option, I.e.

your choice of delay type
net use x: /delete
net use x: //server/share /persistent:no /user:domain/fred password
net use y: //server/share2

etc.

as I presume the dri ve mappings are being put back by windows not a script at the moment?

Steve
regsampAuthor Commented:
Have not tried the ping parameter and the drive mappings are being put back by windows and this is machine is not a member of the domain and does not use a login script.  I am taking a look at the script options mentioned above and starting to try them.  
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Networking

From novice to tech pro — start learning today.