Solved

Modifying folder permissions by command or batch file

Posted on 2008-11-02
10
957 Views
Last Modified: 2012-05-05
I have several computers where the users are not administrators. I recently found out that in order to user a new product these users need to have modify access to 3 folders on the local C drive of their machine. I have ghost solution suite so I have the ability to run batch files remotely on their machines.

I think the easiest way to accomplish what I need to do is just grant the Everyone group modify access to these folders. Is this possible using the command line or a batch file.

Lets assume the folder we need to modify permissions on  is c:\myprogram.
0
Comment
Question by:Joseph Daly
  • 5
  • 4
10 Comments
 
LVL 2

Accepted Solution

by:
m3tech earned 500 total points
ID: 22864140
There are cleaner ways to do this in a domain, but since you didn't mention one, try the following command:

cacls c:\myprogram\*.* /t /e /g everyone:F

This command will change the permissions to all files in c:\myprogram and all subdirectories and files (/t argument), editing permisions instead of replacing (/e argument) and granting (/g argument) everyone full control.

Please test this before applying. Type cacls alone in a cmd prompt for more info.
0
 
LVL 77

Expert Comment

by:Rob Williams
ID: 22864144
You can use xacls.exe within a batch file to modify NTFS permissions if this helps you, but but for the recod it doesn't affect share permissions.
http://support.microsoft.com/kb/318754
0
 
LVL 2

Expert Comment

by:m3tech
ID: 22864148
I just re-read your post use "everyone:C" to grant "change" permissions instead of full control.
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 2

Expert Comment

by:m3tech
ID: 22864153
Please note that xCacls.exe is a Windows 2000 version of cacls.exe that must be downloaded. cacls.exe is installed with windows and should always be available.
0
 
LVL 35

Author Comment

by:Joseph Daly
ID: 22864168
M3tech: I just took a look at the /? for CACLS.exe and it looks like what you gave me up there will work. Im gonna wait until tomorrow morning when I get into work to test it but if it works the points are all yours.

Thanks
0
 
LVL 2

Expert Comment

by:m3tech
ID: 22864187
No hurry, let me know if there are any problems. Incidentally, this same command will let you take permissions/ownership of ntfs drives/folders in XP home without requiring a reboot into safe mode (my primary use for it :p)
0
 
LVL 35

Author Comment

by:Joseph Daly
ID: 22867027
Ok so I just tried this this morning and I ran into some problems here is what I did.

1. Created a new folder on my local C drive called test.
2. The folder looks like it inherited the default permissions
3. I ran the command "cacls c:\test\*.* /t /e /g users:F"
4. Checked the folder permissions and they did not change.

The batch file looks like it complete successfully and didnt return any errors however the security did not change. I have attached a screenshot of the folder permissions below. Now it looks like it changed the permissions on the files within the folder but I also need the ability to change it on the folder itself.
1.jpg
0
 
LVL 35

Author Comment

by:Joseph Daly
ID: 22867240
Actually I think I might have it. I changed the CACLS command to.

"c:\test /t /e /g users:F" and it looks like it did it.
0
 
LVL 35

Author Closing Comment

by:Joseph Daly
ID: 31512566
Awesome answer. Exactly what I needed.
0
 
LVL 2

Expert Comment

by:m3tech
ID: 22873781
I'd have to play with the commands myself, although I see where your problem came into play with the example I gave and it looks like that your code may fix the issue.

If you find it doesn't, you could always add another calcs.exe command to your batch file and process the folder and files/subdirectories seperately. Not clean, but eh.
0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question