mohammadezazi Posted September 19, 2013 Posted September 19, 2013 Hi. Please help me to create a share folder with these permissions (in Domain invironment): Just: Everyone Read CurrentUser Read and Write I use a code such this : (But it is not that i want) The Share permissions is not important for me, but the Security permissions is my weakness. expandcollapse popup#include <Permissions.au3> #include <Process.au3> #include <Misc.au3> #include <GUIConstantsEx.au3> _InitiatePermissionResources() If DirCreate("d:\"&@ComputerName) Then $mypath = "d:\"&@ComputerName ElseIf DirCreate("E:\"&@ComputerName) Then $mypath = "E:\"&@ComputerName ElseIf DirCreate("F:\"&@ComputerName) Then $mypath = "F:\"&@ComputerName ElseIf DirCreate(@DocumentsCommonDir&"\"&@ComputerName) Then $mypath = @DocumentsCommonDir&"\"&@ComputerName EndIf Runwait(@ComSpec & " /c net share "&@ComputerName&"="&$mypath ) $TI = TimerInit() $ret = _myGrantReadAccess($mypath,$SE_FILE_OBJECT,'Administrators') $ret = _myGrantAllAccess($mypath) $TD = TimerDiff($TI) _ClosePermissionResources() Func _myGrantReadAccess($oName, $_SE_OBJECT_TYPE = $SE_FILE_OBJECT, $SetOwner ='Administrators', $Recurse = 1) Local $aPerm[6][3] $aPerm[0][0] = 'Everyone' $aPerm[0][1] = 1 $aPerm[0][2] = $GENERIC_WRITE ;$aPerm[1][0] = $regloginuser $aPerm[1][0] = 'Administrators' $aPerm[1][1] = 1 $aPerm[1][2] = $GENERIC_ALL $aPerm[2][0] = 'System' $aPerm[2][1] = 1 $aPerm[2][2] = $GENERIC_ALL Return _SetObjectPermissions($oName, $aPerm, $_SE_OBJECT_TYPE, $SetOwner, 1, $Recurse) EndFunc ;==>_GrantReadAccess Func _myGrantAllAccess($oName, $_SE_OBJECT_TYPE = $SE_FILE_OBJECT, $SetOwner = 'Administrators', $Recurse = 1) Local $aPerm[1][3] $aPerm[0][0] = 'Everyone' $aPerm[0][1] = 1 $aPerm[0][2] = $GENERIC_ALL Return _SetObjectPermissions($oName, $aPerm, $_SE_OBJECT_TYPE, $SetOwner, 1, $Recurse) EndFunc ;==>_GrantAllAccess
water Posted September 19, 2013 Posted September 19, 2013 You need to add some error checking to your script. How do you know if there is a problem with _SetObjectPermissions and the permissions haven't been set properly? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
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