Jump to content

Recommended Posts

Posted

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.

mapnetworkdrive_tech.vbs

techlogon_file.doc

Posted

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.

drive_mapping.vbs

Posted

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

Posted

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

 

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

Posted

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.

Posted

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

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?

Posted

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.

Posted
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

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.

Posted
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.

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

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.

Posted

I've used batch files for mapping drives for years, but I find that VB script much more flexible and reliable.

 

It allows us very easily to decide who has what drives simply by changing group memberships, how simple can you get! It runs very quickly and very reliably with nothing visible to the user while it executes, and one script does the lot, all users run the same script, so I only need to modify one script if I change drive mappings etc.

 

I love VB scripts, I also have one for printer mapping, and several other ones that do different things for me.

 

Mike.

Posted
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.

 

Completely agree with the KISS idea - I'd guess some people have different ideas of what that entails :-)

 

Lots of batch files seem like a really bad idea - it's just more things to keep track of. Also, I think that if you want to run batch files you have to let users have read/execute access to cmd.exe - this means that they will get to a command prompt at some point. If this doesn't matter then there's no problem :-)

 

The other issue is that each batch file needs a copy of cmd.exe launching which takes time - probably not a big issue but something to think about.

 

going for a single login script which handles all login situations seems simple to me - mine is split up into sub-routines for different purposes (eg one maps printers; another connects the correct proxy server (different for different sites and users); another sets the web home page and so on.

 

Much of this could be done in batch files but I find VBScript much more flexible and easier to debug so that's the way I go.

 

Obviously, other people have different needs/abilities/boredom levels etc and will do their own thing - variety is good because it leads to new discoveries :-)

Posted
mine is split up into sub-routines for different purposes (eg one maps printers; another connects the correct proxy server (different for different sites and users); another sets the web home page and so on.

That sounds like a good script

Any chance we could get a peek?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...