No announcement yet.

Beginner in Scripting.... Need to Map Network Drive for User

  • Filter
  • Time
  • Show
Clear All
new posts

  • Beginner in Scripting.... Need to Map Network Drive for User

    Hey folks,

    Environment: Windows 2003 Server AD
    Clients: Mixture of Win2K and Win XP Pro

    I am a newbie at window scripting so I need some of your knowledge and expertise on this matter. I have about 300 users and I want my users when logging into Domain to automatically map a network drive on a file server . I want my users to able to save their documents on this mapped drive. How do I go about doing this? Any help is greatly appreciated.



  • #2
    Net use

    You can achieve that in may ways. I suppose the simplest one is to use the command Net use in the logon script.

    Net use
    Connects a computer to or disconnects a computer from a shared resource, or displays information about computer connections. The command also controls persistent net connections.

    net use [devicename | *] [\\computername\sharename[\volume]] [password | *]] [/user:[domainname\]username] [[/delete] | [/persistent:{yes | no}]]

    net use devicename [/home[password | *]] [/delete:{yes | no}]

    net use [/persistent:{yes | no}]



    Used without parameters, net use retrieves a list of network connections.


    Assigns a name to connect to the resource or specifies the device to be disconnected. There are two kinds of device names: disk drives (D: through Z and printers (LPT1: through LPT3. Type an asterisk instead of a specific device name to assign the next available device name.


    Specifies the name of the server and the shared resource. If computername contains blank characters, enclose the entire computer name from the double backslash (\\) to the end of the computer name in quotation marks (" "). The computer name may be from 1 to 15 characters long.


    Specifies a NetWare volume on the server. You must have Client Service for NetWare (Windows 2000 Professional) or Gateway Service for NetWare (Windows 2000 Server) installed and running to connect to NetWare servers,


    Specifies the password needed to access the shared resource.


    Produces a prompt for the password. The password is not displayed when you type it at the password prompt.


    Specifies a different user name with which the connection is made.


    Specifies another domain. For example, net use d:\\server\share /user:admin\mariel connects the user identifier mariel as if the connection were made from the admin domain. If domainname is omitted, the current logged on domain is used.


    Specifies the user name with which to log on.


    Cancels the specified network connection. If the user specifies the connection with an asterisk, all network connections are canceled.


    Connects a user to the home directory.


    Controls the use of persistent network connections. The default is the setting used last. Deviceless connections are not persistent.


    Saves all connections as they are made, and restores them at next logon.


    Does not save the connection being made or subsequent connections. Existing connections are restored at the next logon. Use the /delete switch to remove persistent connections.


    • #3
      Creating a folder for every user that logs in

      Thanks dude it works.... Now I have another question... How do you make the command automatically create a folder for a user using his/her username? I guess what I'm saying is that I dont want to manually create a folder for every single user I have on the domain.



      • #4
        you got a lot to learn..

        well the following: u must create a batch file (.cmd) and add it to the netlogon.

        from the userproperties add the batchfile as logon script. and ready..
        but are u sure you want use batchfiles?
        Technical Consultant

        MCITP(EA, SA), MCSA/E 2003:Security, CCNA, SNAF, DCUCI, CCSA/E/E+ (R60), VCP4/5, NCDA, NCIE - SAN, NCIE - BR, EMCPE
        "No matter how secure, there is always the human factor."

        "Enjoy life today, tomorrow may never come."
        "If you're going through hell, keep going. ~Winston Churchill"


        • #5
          Well, first off, what are your concerns for security on this shared drive. Do you want every user to have access to their folder only?

          I would recommend you do an export of the Users OU into a file - or any method of exporting the "User login name" from AD that is possible.

          Format the file correctly, and then use some sort of FOR /L statement to 'MD' or make the directory.

          After which, depending on whether or not you want security, set up the appropriate NTFS/Sharing permissions on each folder.

          Then you can either change the Profile to map the drive at logon, or create a batch file to net use DRIVELETTER: \\SERVERNAME\%USERNAME% (so long as it is shared and perm's are set up OK)

          It's better that YOU do the work here.
          Create the folders.
          Set up the NTFS & Sharing perms.
          Update AD or create the batch file and assign it in a GPO.