Keniger Posted March 1, 2013 Posted March 1, 2013 Hello Guys ! I have a little problem, I create programm. And I need change permission to file, as example I wanna to change security tab permission to only read file, (Cant be run only read) Is that possible to do ? I don't want FileSetAttrib - Its not the same thing that I wanted ;x
Moderators JLogan3o13 Posted March 1, 2013 Moderators Posted March 1, 2013 (edited) Hi, Keniger. Are you talking about setting NTFS permissions on a per-user basis? Below is something I threw together a couple years ago that works for setting permissions on a directory; needs some consolidating but it may give you a place to start: $UID = InputBox("Grant Access", "Enter the user ID") $dir = InputBox("Directory", "UNC path to parent directory") $perm = InputBox("Level of Access", "Enter the level of Access: C(hange), F(ull control), R(ead only), W(rite)") While 1 $dir2 = FileSelectFolder("Choose a folder.", $dir, 1) RunWait( 'CACLS "' & $dir2 & '" /E /G ' & $UID & ':' & $perm, "", @SW_HIDE ) $ok = MsgBox(4, "Complete", "Would you like to specify another directory?") If $ok = 7 Then ExitLoop WEnd MsgBox(0, "Access Granted", "Access has been granted to the specified directories.") Edited March 1, 2013 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
kylomas Posted March 1, 2013 Posted March 1, 2013 Keniger,Seems that cacls is deprecated with Win7 (if that is what you are using) although some report that it still works...see this threadkylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill
Moderators JLogan3o13 Posted March 1, 2013 Moderators Posted March 1, 2013 I just tried this script on a couple directories (as I admit, it has been some time since I played with it). It seemed to set the permissions just fine on Win7 x64. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
kylomas Posted March 1, 2013 Posted March 1, 2013 I just tried this script on a couple directories (as I admit, it has been some time since I played with it). It seemed to set the permissions just fine on Win7 x64.Yes, the threads I've read report mixed reuslts in Win7...Just thought th OP should be aware of this..kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill
Kondro Posted August 28, 2014 Posted August 28, 2014 (edited) This is great! Ive been looking for a way to change folder permisions for our apps the require Admin rights to run, but without giving full local admin rights. it works great when i input my AD user name but does not work if i enter "Domain Users". I modified the script to not promp and directly told it what user and folder to modify. (Script Below) Any idea what i could try to make it find a AD group VS a user? $UID = "Domain Users";InputBox("Grant Access", "Enter the user ID") $dir = "C:Temp";("Directory", "UNC path to parent directory") $perm = "W";InputBox("Level of Access", "Enter the level of Access: C(hange), F(ull control), R(ead only), W(rite)") While 1 $dir2 = "C:Temp";FileSelectFolder("Choose a folder.", $dir, 1) RunWait( 'CACLS "' & $dir2 & '" /E /G ' & $UID & ':' & $perm, "", @SW_HIDE ) $ok = MsgBox(4, "Complete", "Would you like to specify another directory?") If $ok = 7 Then ExitLoop WEnd MsgBox(0, "Access Granted", "Access has been granted to the specified directories.") Edited August 28, 2014 by Kondro
Kondro Posted August 28, 2014 Posted August 28, 2014 I figured it out - changed domin users call to '"Domain Users"'
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now