+ Post New Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 18
Scripts Thread, Map network drives in Coding and Web Development; I have just started learning visual basic programming a few weeks ago. I have been trying to create a logon ...
  1. #1

    Join Date
    Dec 2006
    Location
    US
    Posts
    302
    Thank Post
    64
    Thanked 17 Times in 16 Posts
    Rep Power
    19

    Map network drives

    I have just started learning visual basic programming a few weeks ago. I have been trying to create a logon script that will automatically connect several network drives for the user.

    (User groups are different OUs, and each OU is linked to a different batch file that loads the correct visual basic script, so students see student drives, teachers see teacher drives, and so on)

    The batch file successfully calls the visual basic file. This batch file also disconnects any network drives left from a previous session. The visual basic file does map the network drives. However, it keeps saying drive letter already in use, or something along those lines.

    How do y'all do network drive mapping? Anyone have any suggestions on how I can improve on my method to eliminate the error? Users keep emailing saying the computer has an error.

    I attached the two files.
    Attached Files Attached Files

  2. #2

    maniac's Avatar
    Join Date
    Feb 2007
    Location
    Kent
    Posts
    3,087
    Thank Post
    210
    Thanked 432 Times in 312 Posts
    Rep Power
    145

    Re: Map network drives

    This is the script I use. (attached below)

    It was modified from a script I found on a scripting site. It works extremly well and is very reliable, and the best bit is it runs completely in the background.

    It maps drives according to group membership in AD, so all we need to do is add and remove people from various groups to change the drives they get.

    Mike.
    Attached Files Attached Files

  3. #3

    plexer's Avatar
    Join Date
    Dec 2005
    Location
    Norfolk
    Posts
    13,689
    Thank Post
    756
    Thanked 1,715 Times in 1,526 Posts
    Rep Power
    438

    Re: Map network drives

    I started to sweat while I was reading it as you said you were doing visual basic programming as I thought that would be overkill for this situation.

    Visual basic being the fully blown language with gui editor etc... and not just vb script which is what you are actually doing.

    Ben

  4. #4

    Ric_'s Avatar
    Join Date
    Jun 2005
    Location
    Boston, MA
    Posts
    7,601
    Thank Post
    110
    Thanked 771 Times in 599 Posts
    Rep Power
    183

    Re: Map network drives

    Check out the MS site at http://www.microsoft.com/technet/scr...r/default.mspx - some very good resources and snippits of code you can steal and piece together.

    Incidentally, you shouldn't need the batch file bit at all once your script is complete.

  5. #5

    Join Date
    Dec 2006
    Location
    US
    Posts
    302
    Thank Post
    64
    Thanked 17 Times in 16 Posts
    Rep Power
    19

    Re: Map network drives

    Maniac, thanks for the script. It does work wonderfully and solved the problem (plus logon times are now faster, since the script is quicker )

    Ric, thanks for the link to the MS site. I have bookmarked that page. I am sure I'll be using it a lot.

  6. #6

    maniac's Avatar
    Join Date
    Feb 2007
    Location
    Kent
    Posts
    3,087
    Thank Post
    210
    Thanked 432 Times in 312 Posts
    Rep Power
    145

    Re: Map network drives

    No problem, glad you found it helpful. Wish I could take credit for actually writing it, but I can't as I found it on a VBS scripting site!

    Mike.

  7. #7
    thom's Avatar
    Join Date
    Jul 2005
    Location
    Bedford, East Anglia, UK
    Posts
    242
    Thank Post
    4
    Thanked 6 Times in 5 Posts
    Rep Power
    21

    Re: Map network drives

    I do mine at a lot more basic level.

    In group policy I assign a logon script to the gpo.
    e.g. I assign "mapStudents.bat" to "Students" GPO
    The script contains the same text as you would put in a command prompt
    Code:
    net use s: \\Server\Share
    This means I have a different script for each group (staff/students/visitors). IT seems to work fine for us.
    Are there any advantages to using Maniac's script apart from sorting everybody with one script?

  8. #8

    webman's Avatar
    Join Date
    Nov 2005
    Location
    North East England
    Posts
    8,422
    Thank Post
    645
    Thanked 967 Times in 667 Posts
    Blog Entries
    2
    Rep Power
    328

    Re: Map network drives

    Don't forget you can use net use * /d /y to delete all network drives at once instead of individually.

  9. #9
    tarquel's Avatar
    Join Date
    Jun 2005
    Location
    Powys, Mid-Wales, UK
    Posts
    1,740
    Thank Post
    13
    Thanked 45 Times in 35 Posts
    Rep Power
    30

    Re: Map network drives

    I've been using it for years thom in the same way you describe.

    I guess the only snag is havingto edit multiple batch files, but thinking about it, you could make a single batch script [i just havent had time to investigate it].

    Nath.

  10. #10

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,159
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    125

    Re: Map network drives

    Quote Originally Posted by thom
    I do mine at a lot more basic level.

    In group policy I assign a logon script to the gpo.
    e.g. I assign "mapStudents.bat" to "Students" GPO
    The script contains the same text as you would put in a command prompt
    Code:
    net use s: \\Server\Share
    This means I have a different script for each group (staff/students/visitors). IT seems to work fine for us.
    Are there any advantages to using Maniac's script apart from sorting everybody with one script?
    The real problem is that it doesn't scale and is inflexible. eg what happens when you want to add a mapped drive for both students and staff? You now have to edit both the files and remember that both need editing in the future. If you are sure that you're not going to want to go more complex then there's no problem with the way you're working.

  11. #11

    localzuk's Avatar
    Join Date
    Dec 2006
    Location
    Minehead
    Posts
    18,529
    Thank Post
    527
    Thanked 2,648 Times in 2,049 Posts
    Blog Entries
    24
    Rep Power
    925

    Re: Map network drives

    Not really srochford. You could have a batch file which is called by the other 2 - and this one would list any drives that are used by both.

  12. #12
    thom's Avatar
    Join Date
    Jul 2005
    Location
    Bedford, East Anglia, UK
    Posts
    242
    Thank Post
    4
    Thanked 6 Times in 5 Posts
    Rep Power
    21

    Re: Map network drives

    what happens when you want to add a mapped drive for both students and staff?
    The staff and students are in "School_Users" OU.
    I have a logon script in "School_Users" that maps any drives that both groups need.

  13. #13

    Ric_'s Avatar
    Join Date
    Jun 2005
    Location
    Boston, MA
    Posts
    7,601
    Thank Post
    110
    Thanked 771 Times in 599 Posts
    Rep Power
    183

    Re: Map network drives

    @localzuk: Calling one batch file from within another is less efficient... just think of all those extra CPU cycles being used up! :P

  14. #14

    mattx's Avatar
    Join Date
    Jan 2007
    Posts
    9,249
    Thank Post
    1,061
    Thanked 1,070 Times in 626 Posts
    Rep Power
    741

    Re: Map network drives

    Not wanting to sound a tad over the top but it amazes me the level people go to just to map a few drives.
    I use a nice and simple batch script on logon, a few net use commands and if a drive needs mapping after this event for a certain application then a quick AutoIT launch script using the DriveMapAdd command.
    KIS - Keep It Simple.

  15. #15

    Join Date
    Apr 2007
    Posts
    2
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Re: Map network drives

    We also prefer "net use" commands for the simple mappings. When we we need something more advanced - vbs scripts. I would suggest to look through Markdmac's Login Scripts:

    http://www.tek-tips.com/faqs.cfm?fid=5798



SHARE:
+ Post New Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Hide mapped network drives
    By timbo343 in forum Windows
    Replies: 11
    Last Post: 2nd April 2012, 10:06 AM
  2. Map network drives on wireless network
    By woody in forum Windows
    Replies: 24
    Last Post: 1st December 2007, 07:27 PM
  3. Replies: 5
    Last Post: 26th November 2007, 07:40 PM
  4. Mapping Network Drives ?
    By mac_shinobi in forum Scripts
    Replies: 9
    Last Post: 8th March 2007, 04:49 PM
  5. Map network drives
    By timbo343 in forum Scripts
    Replies: 7
    Last Post: 1st March 2007, 07:46 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •