• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 622
  • Last Modified:

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:", "\\adroot.pma.co.uk\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!


  • 2
1 Solution
whats userstring!??

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

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

WSHNetwork.MapNetworkDrive "R:", "\\adroot.pma.co.uk\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

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

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