[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 572
  • Last Modified:

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.
0
fselliott
Asked:
fselliott
1 Solution
 
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
 
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

Featured Post

 The Evil-ution of Network Security Threats

What are the hacks that forever changed the security industry? To answer that question, we created an exciting new eBook that takes you on a trip through hacking history. It explores the top hacks from the 80s to 2010s, why they mattered, and how the security industry responded.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now