StOnge Posted February 23, 2009 Share Posted February 23, 2009 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 More sharing options...
PsaltyDS Posted February 23, 2009 Share Posted February 23, 2009 (edited) 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 February 23, 2009 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 More sharing options...
Bert Posted February 23, 2009 Share Posted February 23, 2009 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') The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
StOnge Posted February 23, 2009 Author Share Posted February 23, 2009 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: 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 More sharing options...
Developers Jos Posted February 23, 2009 Developers Share Posted February 23, 2009 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 More sharing options...
PsaltyDS Posted February 23, 2009 Share Posted February 23, 2009 (edited) 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 February 23, 2009 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 More sharing options...
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