mujtba Posted January 11, 2006 Share Posted January 11, 2006 Hi ,Im REAL new with VB and scripting. Im more into networking. I have about 4 departments. I want to MAP the users to their shared drives on the network, and I also want to map their My Documents folder to their shared drive on the network. How do I do that? I found the following snippet on microsoft:Const ENGINEERING_GROUP = "cn=engineering"Const FINANCE_GROUP = "cn=finance"Const HUMAN_RESOURCES_GROUP = "cn=human resources"Set wshNetwork = CreateObject("WScript.Network")wshNetwork.MapNetworkDrive "h:","\\FileServer\Users\" & wshNetwork.UserNameSet ADSysInfo = CreateObject("ADSystemInfo")Set CurrentUser = GetObject("LDAP://" &ADSysInfo.UserName)strGroups = LCase(Join(CurrentUser.MemberOf))If InStr(strGroups, ENGINEERING_GROUP) Then wshNetwork.MapNetworkDrive "g:", "\\FileServer\Engineering\" wshNetwork.AddWindowsPrinterConnection "\\PrintServer\EngLaser" wshNetwork.AddWindowsPrinterConnection "\\PrintServer\Plotter" wshNetWork.SetDefaultPrinter "\\PrintServer\EngLaser"ElseIf InStr(strGroups, FINANCE_GROUP) Then wshNetwork.MapNetworkDrive "g:", "\\FileServer\Finance\" wshNetwork.AddWindowsPrinterConnection "\\PrintServer\FinLaser" wshNetWork.SetDefaultPrinter "\\PrintServer\FinLaser"ElseIf InStr(strGroups, HUMAN_RESOURCES_GROUP) Then wshNetwork.MapNetworkDrive "g:", "\\FileServer\Human Resources\" wshNetwork.AddWindowsPrinterConnection "\\PrintServer\HrLaser" wshNetWork.SetDefaultPrinter "\\PrintServer\HrLaser"End IfMy info:Departments:ITQAFinanceEngineeringExecutiveFileserver:Neptune1Nas1I will use Group Policy in AD to implement this. All users have 2000 or XP. So I want to look at the department, and MAP users to their drives. Can someone modify the code for me to reflect that?Thanks Link to comment Share on other sites More sharing options...
jondercik Posted January 11, 2006 Share Posted January 11, 2006 Why make it this hard? It would be simpler to just use a batch file and assign it to the correct OU and use the "net use" command. There is really no need for all the comparisions.Just my opinion.Jim Link to comment Share on other sites More sharing options...
mujtba Posted January 11, 2006 Author Share Posted January 11, 2006 but if I used batch files, I would need to have a SEPERATE batch file for each OU. If I use a .vbs file, I can have ONE file and just compare the dept and allow users access... Link to comment Share on other sites More sharing options...
jondercik Posted January 11, 2006 Share Posted January 11, 2006 (edited) yes you would need one for each OU but it would only be two lines long:net use driveletter: /d (optional but I would do it in order to assure the correct mapping)net use driveletter: \\pathtoshareAlso for doucment rediriection you do that via group policy. Edited January 11, 2006 by jondercik Link to comment Share on other sites More sharing options...
mujtba Posted January 11, 2006 Author Share Posted January 11, 2006 But for My Documents, how would I assign all users their MAPPINGs at once? I would do it indivindually through group policy? I have to do this in the quickest manner for my work.. Link to comment Share on other sites More sharing options...
jondercik Posted January 11, 2006 Share Posted January 11, 2006 For redirection its done on an OU basis through Group Policies. Link to comment Share on other sites More sharing options...
mujtba Posted January 12, 2006 Author Share Posted January 12, 2006 anyone can help me with the VBS coding? Link to comment Share on other sites More sharing options...
RogueSpear Posted January 12, 2006 Share Posted January 12, 2006 jondercik is right, you really should do folder redirection via Group Policy. It's a much cleaner method and then you have control over other things like permissions.I have a machine startup script and a user logon script for each OU in my networks. Those scripts then call a master script for those things that are common enterprise wide. I learned over the years that it truly is better to break things up sometimes into smaller more manageable chunks rather than have one huge unweildy script. If you do chose to go the one big script route and then you have to change something for say one or two groups of people, you rish breaking the script for the entire enterprise. Not good. Link to comment Share on other sites More sharing options...
mujtba Posted January 12, 2006 Author Share Posted January 12, 2006 no, not at all. the script is in VB.. you can do SO MUCH in that one script.. i will just point all depts. to that script and dont touch group policy again.. anytime i need to change something, i just edit the vbs file. i read a lot of places to use a .vbs file, as opposed to the batch files for more control. theres a lot that can be done. Link to comment Share on other sites More sharing options...
jondercik Posted January 12, 2006 Share Posted January 12, 2006 That is sorta true. You can do more with wbs files easier than with standard batch files. I am just trying to give you the best solution for the problem you asked. Like I said before since the OUs are already there I would create 1 script per OU so that if there are any more things that need to be set per department all you have to do is edit a much simpler file rather than a much more complicated file.I do agree that the script you are trying to do can do alot, it just doesnt seem appropriate to use it. Link to comment Share on other sites More sharing options...
RogueSpear Posted January 12, 2006 Share Posted January 12, 2006 no, not at all. the script is in VB.. you can do SO MUCH in that one script.. i will just point all depts. to that script and dont touch group policy again.. anytime i need to change something, i just edit the vbs file. i read a lot of places to use a .vbs file, as opposed to the batch files for more control. theres a lot that can be done.First of all I was referring to vbs when talking about my scripts. Second if you're insistent upon making one single script.. by all means go ahead, it's your network. I guess some people need to learn the hard way. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now