Writing a batch file

Posted on 2013-12-26
Medium Priority
Last Modified: 2013-12-29
To all the scripting guru's out there (admittedly I am not one)... I know enough about active directory to know that it is possible (preferred) to have drive mapping done by security permissions, but alas, I missed that class of scripting 101. What I would like is to have a script that has an array of possible drives to be mapped but will only map the drives if the appropriate NTFS permissions are met, any assistance to this end would be very well appreciated.
This can be accomplished using either Visual Basic, a Batch file, or Powershell whatever the preferred method I would like it to be scalable and easy so changes can be made on the fly with even the least savvy IT person able to edit it, thanks.
Working in a Windows environment with Win 7 and a mix of Server 2003 and 2008 R2, this would be a logon script an added bonus would be to have the same script be able to assign printer based on group security permissions too...
Question by:juslearning
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2

Expert Comment

ID: 39741296
It isn't actually scripting really, and it easier to do through AD- IMHO.

is a decent one on this.  My only comment is to make your names of the security groups or your GPO reflect the drive letters (if it matters) or more descriptive as possible.    They kind of gloss over this, so in AD, you would have already made a security group that allows access to the drive.  I also remove the default authenticated users from the second window and add my security group in AD.  I tend to use the same one if possible, so the drive only shows up if they also have rights to do something in it.

If you leave it as authenticated user, then everyone will get the drive, but when they double click it will say access denied.

When you want a particular person to have a drive, you will then jsut add them in AD to the security group you had the GPO apply to, then have them log out and back in...

Author Comment

ID: 39741833
Part of the issue is I do not want to handle it using GPOs as not all folks following me in the job will be savvy with AD and GPOs also I am low in the totem pole regarding domain level rights. So keeping it local with regards to a logon script so that anyone with local domain admin rights can edit, makes life easier and less to explain, you know what I mean?

Accepted Solution

tsaico earned 600 total points
ID: 39741990
Not really, since the term "local domain admin" refers to a user who can do what they want anywhere, regardless if at local or domain level.  If you mean local admin rights, then this is also a bad idea since your end users should not have local admin rights.  But regardless, if that the direction you wanted to go in, that is entirely your prerogative.  I know sometimes politics or personalities can interfere with managing systems.

So back to the OP,

I found was a decent site for scripting help.  In your case, you can hid the kixart and VB stuff, then focus on how to do drive mapping on a group membership basis.  (command line)  When you get the immediate need done, then you can start checking out the VBscripting part and start practicing on that.

It also has information on how to add to the batch doing network printers, since that is usually the second thing admins want to do after drives and that can make your life easier too, which is really what any of this stuff is for.
LVL 43

Expert Comment

by:Steve Knight
ID: 39742809
I have an example login script here too in VBScript of mine which shows results in a status window using IE etc.


For anything new I would be using Group Policy preferences too, otherwise a group policy based login script allocated to relevant containers, though I understand that some people do prefer to point specific user login scripts using their user property instead / aswell.

Whichever way you end up doing it you aren't going to get the drives mapped based on the NTFS permissions, aside from anything else you could have NTFS permissions allowing / denying access for a user at  x:\somedir but they have access to a specific file in that dir or a level durther down.

Share permissions you could read I suppose but the most logical is to use groups, either:

Group "Map drive X to server1-share1" - check for this in login script
Group "Some users in this group" - put users in this group, and put group in "Map x drive ...." etc. or check if the user is in "some users in this group" and map the drive.

Other more logical ways of course is to use DFS, the user has one or more drives mapped to \\domain.local\dfs-share  and then under that you create links to the actual shares they need.

Waffled on a lot more than intended to there but you get the idea, ask questions if needed.

Author Comment

ID: 39744242
I will test these out first thing when I return to work, thanks so far for all the input...

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Multi-threading long-running processes can have a significant increase in overall performance and drastically decrease over time it takes for a process to complete. Unfortunately, not all applications support native multi-threading, some by design a…
In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month12 days, 23 hours left to enroll

777 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