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

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

Logon Script Map Network Drive

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
netsmithcentral
Asked:
netsmithcentral
  • 6
  • 6
1 Solution
 
sirbountyCommented:
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
 
netsmithcentralAuthor Commented:
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
 
sirbountyCommented:
Only thing I could think of then is if P is already mapped somehow - are you testing for this in your script somewhere?
0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
netsmithcentralAuthor Commented:
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
 
LauraEHunterMVPCommented:
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
 
netsmithcentralAuthor Commented:
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
 
sirbountyCommented:
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
 
netsmithcentralAuthor Commented:
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
 
sirbountyCommented:
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
 
netsmithcentralAuthor Commented:
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
 
sirbountyCommented:
Good luck!
0
 
netsmithcentralAuthor Commented:
Alright, everything is still running smoothly.  Looks like whatever it was worked itself out.
0
 
sirbountyCommented:
Happy to help - thanx for the grade! :^)
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 6
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now