Mapping a DFS share to a drive

Hi All,
I have a login script that currently maps all our users network drives.  The users have a home directory which is mapped to the R: drive by this command in vb:

WSHNetwork.MapNetworkDrive "R:", "\\Tiger\Users" & UserString,True

I have recently introduced DFS to the comany and setup a namespace with the 'users' folder as a target:


Now when I try and map a drive to:

WSHNetwork.MapNetworkDrive "R:", "\\\pma_users\Users" & UserString,True

using my script it fails - does anyone know why this wont work? Can I map drives with DFS using variables?

Any help greatly appreciated!


Who is Participating?
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.

whats userstring!??

use the below. It will create a net work drive to:

set WSHNetwork= CreateObject("") 
Set objShell = CreateObject("Wscript.Shell") 

WSHNetwork.MapNetworkDrive "R:", "\\\pma_users\Users\" &objShell.ExpandEnvironmentStrings("%USERNAME%")

Open in new window

robclarke41Author Commented:
Userstring was a variable I was using before - it seemed to work ok!

I've just tried your solution and it seems to work great! Thanks! I'm just doing some more testing.
allright. if you've any further points..feel free to ask

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
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
Project Management

From novice to tech pro — start learning today.