Create batch file to map user folder

Posted on 2006-05-09
Last Modified: 2008-01-09
Where to begin.
Company has ONE main DC, w/7 out of state servers; which run as DC's, but aren't included in the MAIN DC, only the users's exist, in their OU's according to location.

I want to create a batch file to add to the OU of the users.  I could either create a GP for each OU, but would rather have the info stored under the Profile Tab->
Profile Tab ->
User Profle
Profile Path:
Logon Script:


Home Folder
Local path:
Connect:  To:

I honestly would prefer this area User Profle
Profile Path:
Logon Script:
so Admins can see the batch file, info, etc.

How can I create a batch file, that will "carry down" to all the OU's?  The way AD is setup, is we have one main OU  called Company Users and then under that we have OU's for our 7 outer offices, as well as having OU's which DO NOT need user mapping.  So,  I'd like to create a batch file that will populate the necessary path, such as \\server\users and create the user folder according to the user logon name and their counting OU.  All the Servers use the same syntax for mapping the user folders, they're all \\servername\users and all map the L: drive.  What we've been doing is manually going to the necessary server and created the user folder.

Know there's any easy way to do this but haven't found exactly what I'm looking for on EE.  Like I said, I'd prefer the info to be entered under the User's Profile tab and would like to also know how to fill in that information automatically w/out copying the path info to each user manually.

I'll need exact scripting b/c I'm not familiar.  Thanks!
Question by:mdmcq5
    LVL 4

    Expert Comment

    the way to go would be creating a vb-script and using the WinNT-provider , that way the OU's don't matter.

    Of course , you need to know some vbs...

    the 2003 commandline tool dsmod could also be handy , but you would have to dive into all the commandline options.
    LVL 4

    Expert Comment

    actually - there is an easier way: (assuming you run 2003)

    create a share where you want to store your profiles , set full access to everyone on the share.

    in AD User&Computers go to an ou with users and select multiple users you wish to modify by clicking them and holding the CTRL-key,
    or press ctrl-a if you want to modify them all.

    Then right-click on the selected users and choose ' properties' .
    Go to the profile tab and for the profile property type \\servername\sharename\%username%

    Replace \\servername\sharename with the UNC-path where you want to store the profiles.
    Windows will replace the variable "%USERNAME%"  with the logon-name of the user being processed.
    Windows will create a subfolder for every user and set permissions for you.

    hope this helps!
    There are several properties that can be modified this way.

    Author Comment

    what if the folders already exist; will the settings be erased?

    Author Comment

    I'd like the \\servername\sharename\%username% idea, but what about new user's being added to the OU, then a GP would have to be created, right?
    LVL 4

    Accepted Solution

    sorry for the slow response

    as far as I know you can't set profiles property through Group Policy.

    I would create a template user , assign this template user it's homedrive and profile as \\server\sharename\%username% ,
    then if you need a new user , right-click your template user and select copy.
    Then put the template user in the groups that every user needs.
    If you create a user that way , it will autimatically have the right profile and hmedrive and be member of the standard groups.
    You can create a template user in every OU if you like , doesn't matter.

    Hope this helps!
    LVL 4

    Expert Comment

    hi mdmcq5,

    did the template-user thing work for you?

    Author Comment

    yes, thanks.

    Featured Post

    PRTG Network Monitor: Intuitive Network Monitoring

    Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

    Join & Write a Comment

    Suggested Solutions

    Numerous times I have been asked this questions that what is it that makes my machine log on so slow, there have been cases where computers took 23 minute exactly after taking password and getting to the desktop. Interesting thing was the fact th…
    Scenerio: You have a server running Server 2003 and have applied a retail pack of Terminal Server Licenses.  You want to change servers or your server has crashed and you need to reapply the Terminal Server Licenses. When you enter the 16-digit lic…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    729 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

    20 Experts available now in Live!

    Get 1:1 Help Now