[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 727
  • Last Modified:

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.
0
regsamp
Asked:
regsamp
  • 9
  • 5
  • 3
  • +2
5 Solutions
 
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
0
 
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
0
 
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.
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
BLipmanCommented:
write a batch file with sleep.exe

This command will put a pause in for the seconds you specify.  
0
 
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.  
0
 
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
0
 
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.  


0
 
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
0
 
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.  
0
 
BLipmanCommented:
You can always download sleep.exe from the Internet and place the exe on your NETLOGON share or wherever the mapping runs from.  
0
 
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
0
 
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.  
0
 
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
0
 
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.  
0
 
regsampAuthor Commented:
rsivanandan, should we use net use z: /delete before net use Z: \\computerip\sharename /u:domain\username <password> in the batch file?  
0
 
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"
0
 
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?  
0
 
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
0
 
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
0
 
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
0
 
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.  
0

Featured Post

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

  • 9
  • 5
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now