Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


wsh script to map drives referencing domain controller.

Posted on 2004-10-24
Medium Priority
Last Modified: 2008-02-01
I have a network which is run on a single domain using MS Enterprise Server 2003. The domain controls 13 separate sites which each have their own domain controllers.

My boss wants me to implement a wsh script which will allow users to log on to and use only the mapped drives specified for their particular domain controller.

In other words, the drives for each user would be mapped on the domain controller machines as opposed to mapping them on the primary domain controller

I am a novice script writer..

I need help with the script and instructions on installing it.

Please help!


Question by:DrD
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 11

Accepted Solution

WeHe earned 1000 total points
ID: 12395298
You should do that with Group Policies.
i am not sure if you want them to log on to the DC's. Its a security issue to not allow this.
but if yes, you have to modify the "Default Domain Controller Policy"
If they log on to normal clients, the "Default Domain Policy" counts.
browse through it and look if it can do, what you want to do :)

Author Comment

ID: 12396637
The question more specifically is this:

I have to write a scipt using WSH which I would implement using group
The script would map drives to user computers as they log on.
However, since we have one domain but a number of domain controllers (a
domain controller in each site), I need a way to map drives according to the
D.C the user is using to authenicate him/herself.
For example if a user is in Site A,using Domain controller A then the mapped
drive he/she would receive would be X:\ mapped to share A
If a user is in Site B, using Domain controller B then the mapped drive
he/she would receive X:\ mapped to share B.

The WshNetwork object allows you to map drives according to three
properties: UserName, Computer Name and UserDomain

For example to map a network drive according to User Domain would be

Set objNetwork = Wscript.CreateObject ("Wscipt.Network")
strUserDomain = objNetwork.UserDomain

If strUserDomain = "ACCOUNTING" Then
   objNetwork.MapNetworkDrive "X:", "\\fileserver01\accounting", True
Else if strUserDomain = "DEVELOPMENT" Then
   objNetwork.MapNewtorkDrive :X:",  "\\fileserver01\accounting", True
End If

However the WshNetwork object doesn't have a property to map drives
according to the Domain Controller one is trying to authenicate oneself

Does anyone have a way around this?

Assisted Solution

shard26 earned 1000 total points
ID: 12407601
I know a sure fire way in Dos shell scripting

You could use this.

NET USE X: %logonserver%\accounting

This will always map the drive to the share that is attached to the server you logged on from.  Now in some cases your users may log onto a server that is not local.  If this happens then access to that drive will be slow. Hope that helps.  If you have to use a WSH script you could always launch the dos script first then call the wsh script using the logon server as a switch

Start %logonserver%\netlogon\wshscript.vbs %logonserver%

Good luck

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

So you have two Windows Servers and you have a directory/folder/files on one that you'd like to mirror to the other?  You don't really want to deal with DFS or a 3rd party solution like Doubletake. You can use Robocopy from the Windows Server 200…
This may not be a text book method to resolve VSS backup issues but it seemed to have worked on few of the Windows 2003 servers we had issues while performing a Volume Shadow Copy backup. If you have issues while performing a shadow copy backup usin…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

596 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