Jump to content

Setting permissions on folder/file


Recommended Posts

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

Link to comment
Share on other sites

  • Moderators

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 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!

Link to comment
Share on other sites

  • Moderators

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 1 year later...

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 by Kondro
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...