Solved

Logon Script Map Network Drive

Posted on 2007-04-06
13
4,780 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
 
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Issue: Unstable cursor in Windows XP and Windows runs extremely slow in that any click will bring up the Hour glass (sometimes for several seconds before giving you what you want) . Troubleshooting Process and the FINAL FIX: This issue see…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now