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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
darkstar245Commented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
OS Security

From novice to tech pro — start learning today.