Solved

Logon Script Map Network Drive

Posted on 2007-04-06
13
4,787 Views
Last Modified: 2008-07-14
I have a Domain Wide logon script defined that does a ton of stuff.  One thing it's supposed to do is connect the user to our public share, P: using similar code to this:

Dim objNetwork
Set objNetwork = WScript.CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "P:", "\\server\public"
Set objNetwork = Nothing

I'm not getting any errors reported by the script... but for some reason, some users just don't see the public drive letter appear.  Any ideas?
0
Comment
Question by:netsmithcentral
  • 6
  • 6
13 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 18866274
Nothing there that would prevent it.
Do they have permissions to that share?
Can you manually map from a command line
net use p: \\server\public
from their workstation?
0
 
LVL 12

Author Comment

by:netsmithcentral
ID: 18866290
They do have permissions, in fact, if I use the GUI (explorer), I can map the drive manually AFTER the script is done running.  The problem is... the script is supposed to do it.
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18866302
Only thing I could think of then is if P is already mapped somehow - are you testing for this in your script somewhere?
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
LVL 12

Author Comment

by:netsmithcentral
ID: 18866331
P: "shouldn't" be mapped.... it's far enough from the default drive letters that I'm confident it's not taken an onboard device.  This is the only network mapping it should have.  As for checking for it, I don't know how to do that?  Can it be done with WSH/VB?

Another note, if I physically reexecute the script after the initial logon on a user who isn't mapping P properly, it works perfectly.... that is, P maps.
0
 
LVL 30

Expert Comment

by:LauraEHunterMVP
ID: 18866349
You don't have "On Error Resume Next" specified in the script, do you?  This would prevent any script errors from displaying to the user.
0
 
LVL 12

Author Comment

by:netsmithcentral
ID: 18866410
It is in the script, but I've put an On Error Goto 0 right before the drive mapping to make sure. So more accurately, my script is:

On Error Goto 0
Dim objNetwork
Set objNetwork = WScript.CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "P:", "\\server\public"
Set objNetwork = Nothing
On Error Resume Next
0
 
LVL 67

Accepted Solution

by:
sirbounty earned 500 total points
ID: 18866453
Something like this...

On Error Resume Next
strDriveLetter="P:"
strRemotePath="\\server\public"
Set CheckDrive = objNetwork.EnumNetworkDrives()
AlreadyConnected = False
For intDrive = 0 To CheckDrive.Count - 1 Step 2
  If CheckDrive.Item(intDrive) = strDriveLetter Then AlreadyConnected =True
Next

If AlreadyConnected = True then
objNetwork.RemoveNetworkDrive strDriveLetter
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath

ref: http://www.computerperformance.co.uk/Logon/Logon_HomeDirLoop.htm
0
 
LVL 12

Author Comment

by:netsmithcentral
ID: 18867019
Alright, I checked it, the script is NOT reporting that P has been mapped.  Needless to say, I'm pretty baffled by this one.
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18867177
Just curious if this method would work?

Dim objShell:Set objShell=CreateObject("Wscript.Shell")
objShell.Run "net use P: \\server\public"

Does it get mapped using this route?
0
 
LVL 12

Author Comment

by:netsmithcentral
ID: 18867317
Well, I added some checking code to the loop, to see if the drive was mapped immediately after I mapped it... lo and behold, IT WAS.  Now I can't seem to reproduce the original error using any of the original problem accounts.  I'm thinking there must have been some corrupt volume data related to P: that got flushed through the course of my tests, but I'm not sure.

For now, I'll leave this question open for two days just to make sure the problem doesn't suddenly resurface.  If it doesn't, I'll award full points to sirbounty for the helpful examples.
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18867393
Good luck!
0
 
LVL 12

Author Comment

by:netsmithcentral
ID: 18877569
Alright, everything is still running smoothly.  Looks like whatever it was worked itself out.
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18877582
Happy to help - thanx for the grade! :^)
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question