batch script to set user permissions

I've modified a batch script I found to set user permissions. The script creates a folder, then assigns permissions as full control to the "domain admins", "Administrators", and the "username", only it still assigns permissions to others also, for example "Everyone". Can someone please tell me why? I need to secure the folder for use only by the domain admins, administrators and "single" user.

Here's the code:

mkdir \\server\data\reports\username
echo y| calcs "\\server\data\reports\username /G" "Domain Admins":F "Administrators":F username:F

I've tried it several different ways but nothing works. It always creates a folder with full access for everybody in the company.

Thanks.
fselliottAsked:
Who is Participating?
 
darkstar245Connect With a Mentor Commented:
Have you tried to remove everyone permissions by including it in the command?
Also, if I remember correctly, even with the calcs command it's going to inherit the permissions of the reports folder.  What is the access set to on that folder?
0
 
oBdACommented:
That's because the command never actually runs, because
1. the name of the command is cacls.exe, not calcs.exe
2. you don't have the quotes specified correctly
Then it's completely unnecessary to add Domain Admins, because Domain Admins are a member of the local Administrators group by default anyway; add local system instead.

mkdir \\server\data\reports\username
echo y| cacls.exe "\\server\data\reports\username" /G Administrators:F SYSTEM:F username:F

Open in new window

0
 
Kieran_BurnsCommented:
As an alternative I would consider using fileacl
http://www.microsoft.com/downloads/details.aspx?FamilyID=723F64EA-34F0-4E6D-9A72-004D35DE4E64&displaylang=en
which is an excellent and flexible tool for modifying user ACLs
0
 
oBdACommented:
darkstar245,
if cacls is run without /e (*e*dit the ACL), it will *replace* the current ACL with the specified permissions; that's why the "echo y|" is necessary as well. The problem is the incorrect syntax.
0
 
fselliottAuthor Commented:
Yes, thank you, the problem is in the inherited permissions. But how do I remove them completely? I've re-written to this:

echo y|calcs.exe /e "\\server\data\reports\username" /R "CREATOR OWNER"

and it removes permissions, but it still allows it to inherit from parent the special permissions, which allow full access. So it defeats it's purpose.  Please provide guidance. Thanks, Lisa  lischmidt@fs-elliott.com
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.