Link to home
Start Free TrialLog in
Avatar of juslearning

asked on

Writing a batch file

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...
Avatar of tsaico
Flag of Afghanistan image

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...
Avatar of juslearning


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?
Avatar of tsaico
Flag of Afghanistan image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Steve Knight
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.
I will test these out first thing when I return to work, thanks so far for all the input...