Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

set group permissions batch 2

Status
Not open for further replies.

spelltwister

Programmer
May 12, 2005
36
0
0
US
Hey everyone,

I was wondering how to set group permissions with a batch file. I have to create about... 150 groups and need to give them permissions to specific folders.

Is there a command that can be run from a batch file that will set the permissions?

Thanks,

Mike

Online multiplayer strategy games huh? Try, 1483online.com where the games are FREE and the community drives enhancements to the game. ;-D
 
This forum would be able to help out a lot in your question:

forum329

Look in the FAQ's. There may already be something you could use in there. As a matter of fact, this FAQ may specifically help:

faq329-5798

Just as a courtesy, you should probably look into VBScript instead of batch files. VBScript is more powerful, and it's capabilities surpass batch files. Also, less memory intensive (each batch open's a Microsoft VM).
 
I agree with tfq13 in that VBScript is powerful, but there is a learning curve if you are not familiar with it. Also, VBScript does not make all your current tools obsolete. I would use whatever resource gets the job done quickly whether it's VB, batch, and/or utilities. With that said let's tackle your requirements.

1. Create 150 Security groups using a command utility:
DSADD.EXE is a Win2003 admin tool that works with 2003 and 2000(>=SP3) domain controllers. You could call this utility from a batch.
Syntax:
DSADD GROUP "LDAPPath" -secgrp yesno -scope grouptype

LDAPPath e.g.
LDAP://cn=NewGroup,cn=users,dc=domainname,dc=com)
-secgrp yesno yes=security group, no=distribution group
-scope grouptype either l=local, g=global, or u=universal.

Create 150 Security groups using VBScript:
This code reads a text file, which you create, with the names of all the security groups and uses ADSI to create each group. Creat a text file call SecGrps.txt and place it on the root of your C: drive. The SecGrps.txt file should include each security group name, on their own line.
e.g.
Security Group 1
Security Group 2
Security Group 3
etc...

Copy this code and name it SecGrps.vbs. Make sure you put your domian name in the script ("WinNT://yourdomainname").

'==========================================================
On Error Resume Next
Const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("c:\SecGrps.txt", ForReading)
strText = objTextFile.ReadAll
objTextFile.Close
arrSecGroups = Split(strText, VbCrLf)

For Each SecGroup In arrSecGroups
Set DomObj = GetObject("WinNT://yourdomainname")
Set Group = DomObj.Create("group", secGroup)
Group.SetInfo
Next
'===========================================================

2. Now that your 150 Groups are created you need to add your users.
Read my reply on "modifiying group membership in bulk."

You can also use VBScript to do this:
This is an example:
'=========================================================
Set Group = _
GetObject("WinNT://yourdomainName/groupname,group")
Group.Add "WinNT://YourDomainName/useraccount,user"
"==========================================================

3. With the users now members of the groups, add groups to resources and set permissions.
You can add the groups to the NTFS permissions in a batch using the XCACLS.EXE resource kit utilily.
Syntax:
XCACLS c:\sales\repair\*.* /G SecurityGroupName:F

the above example grants the Security Grop the full access right to all files and folders in the repair directory.

Good luck...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top