Jump to content

Set Permissions Of Variable Folders Using SetACL


StOnge
 Share

Recommended Posts

Hi. I'm working on a script that will set permissions to folders within a directory that contains variables. The ultimate goal of the script is to have the user enter in a client name, project code, and group, and then have the project code folder be created inside of the client's folder, with permissions set to the group specified by the user.

So far, I was able to get the project code folder to be created inside of the client's folder, and have the heirarchy of folders copied from a template located elsewhere on the partition. Now I am stuck on allowing the group access to the folders.

The problem lies in the syntax of this line of code. I think I am caught up in the quotation marks apostrophes.

;Give the group permission to the project

Run('D:\Test\SetACL\setACL.exe -on "D:\Test\Clients" ' & $client & '\' $code & '\Analysis" -ot file -actn ace -ace n: ' & $group & ';p:read,write,del_child')

Any help would be greatly appreciated! If it helps at all, here is the entire code so far:

;Gather client name and project code

$client = InputBox("Client Name", "Please enter the name of the client.")
$code = InputBox("Project Code", "Please enter the name of the project code.")
$group = InputBox("Group Name", "Please enter the name of the group that will have access to the project.")


;Create the project directory in the client folder

DirCreate("D:\Test\Clients\" & $client & "\" & $code)
Sleep(1500)
Run("C:\WINDOWS\EXPLORER.EXE /n,/e,D:\Test\Clients\" & $client & "\" & $code)
WinWaitActive($code)
Sleep(1500)


;Copy the folder template with permissions into the project directory

Run('robocopy "D:\Test\Template" ' & '"D:\Test\Clients\' & $client & '\' & $code & '" /mir /sec')
Sleep(3500)


;Give the group permission to the project

Run('D:\Test\SetACL\setACL.exe -on "D:\Test\Clients" ' & $client & '\' $code & '\Analysis" -ot file -actn ace -ace n: ' & $group & ';p:read,write,del_child')

www.stonge.com

Link to comment
Share on other sites

Hi. I'm working on a script that will set permissions to folders within a directory that contains variables. The ultimate goal of the script is to have the user enter in a client name, project code, and group, and then have the project code folder be created inside of the client's folder, with permissions set to the group specified by the user.

So far, I was able to get the project code folder to be created inside of the client's folder, and have the heirarchy of folders copied from a template located elsewhere on the partition. Now I am stuck on allowing the group access to the folders.

The problem lies in the syntax of this line of code. I think I am caught up in the quotation marks apostrophes.

;Give the group permission to the project

Run('D:\Test\SetACL\setACL.exe -on "D:\Test\Clients" ' & $client & '\' $code & '\Analysis" -ot file -actn ace -ace n: ' & $group & ';p:read,write,del_child')

Any help would be greatly appreciated! If it helps at all, here is the entire code so far:

;Gather client name and project code

$client = InputBox("Client Name", "Please enter the name of the client.")
$code = InputBox("Project Code", "Please enter the name of the project code.")
$group = InputBox("Group Name", "Please enter the name of the group that will have access to the project.")

;Create the project directory in the client folder

DirCreate("D:\Test\Clients\" & $client & "\" & $code)
Sleep(1500)
Run("C:\WINDOWS\EXPLORER.EXE /n,/e,D:\Test\Clients\" & $client & "\" & $code)
WinWaitActive($code)
Sleep(1500)

;Copy the folder template with permissions into the project directory

Run('robocopy "D:\Test\Template" ' & '"D:\Test\Clients\' & $client & '\' & $code & '" /mir /sec')
Sleep(3500)

;Give the group permission to the project

Run('D:\Test\SetACL\setACL.exe -on "D:\Test\Clients" ' & $client & '\' $code & '\Analysis" -ot file -actn ace -ace n: ' & $group & ';p:read,write,del_child'

Try it like this:

$sDir = 'D:\Test\Clients'
$sClient = 'Client Name'
$sCode = 'ProjectCode'
$sGroup = 'Group Name'

;Give the group permission to the project
$sSetACLExe = 'D:\Test\SetACL\setACL.exe'
$sSetACLParams = ' -on "' & $sDir & '\' & $sClient & '\' & $sCode & '\Analysis"' & _
        ' -ot file -actn ace -ace "n:' & $sGroup & ';p:read,write,del_child"'
        
$RET = RunWait($sSetACL & $sSetACLParams)
MsgBox(64, "Return", "$RET = " & $RET)

Note there is one set of double quotes around the complete directory path, and one set around the -ace parameter string.

:)

Edit: Fixed missing '&' pointed out by Jos below.

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

maybe

Run('D:\Test\SetACL\setACL.exe -on "D:\Test\Clients" ' & $client & '\' $code & '\Analysis"'&' -ot file -actn ace -ace n: ' & $group & ';p:read,write,del_child')

I get the following error message when I try that:

Posted Image

PsaltyDS, I'm still messing around with your idea. I'm not exactly sure how the variables work in your suggestion.

Thank you to everyone is who trying to help me. It is greatly appreciated!

www.stonge.com

Link to comment
Share on other sites

  • Developers

There is an & missing between '\' & $code :

Run('D:\Test\SetACL\setACL.exe -on "D:\Test\Clients" ' & $client & '\' & $code & '\Analysis" -ot file -actn ace -ace n: ' & $group & ';p:read,write,del_child')

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

I get the following error message when I try that:

I think Volly forgot the backslash in the path between "Clients" and $client, and also to put double quotes around the -ace parameter string. Note there is an odd number of double quotes (three) in that full command line, which is wrong.

PsaltyDS, I'm still messing around with your idea. I'm not exactly sure how the variables work in your suggestion.

Thank you to everyone is who trying to help me. It is greatly appreciated!

I just like having the parts in easy-to-maintain variables, named according to conventions. Makes maintenance of long scripts easier.

This version is closer to your original, with only the changes I thought necessary:

;Give the group permission to the project
$RET = RunWait('D:\Test\SetACL\setACL.exe -on "D:\Test\Clients\' & $client & '\' & $code & '\Analysis"' & _
        ' -ot file -actn ace -ace "n:' & $group & ';p:read,write,del_child"')
MsgBox(64, "Return", "@error = " & @error & @CRLF & "$RET = " & $RET)

:)

Edit: Doh! Fixed missing '&' pointed out by Jos.

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...