JunkieKing Posted December 30, 2010 Posted December 30, 2010 Hi Gurus~~ Below are the sample script I have created to add a folder with permission expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <ButtonConstants.au3> #include <TreeViewConstants.au3> ;ANT Server Control Panel GUI $ControlPanel = GUICreate("ANT - User Creation Panel", 350, 225, 450, 187) $GroupBox1 = GUICtrlCreateGroup("", 14, 18, 320, 200) GUICtrlCreateLabel("User Creation", 20, 8, 130, 13) ;User Creation GUICtrlCreateLabel("Username", 22, 36, 118, 18) $FolderInput = GUICtrlCreateInput("",22, 52, 118, 18) GUICtrlCreateLabel("Group Permissioning", 20, 80, 130, 17) GUICtrlCreateGroup("", 20, 90, 130, 116) $GroupManagement = GuiCtrlCreateCheckbox("Management",28, 100, 80, 20) $GroupAccounts = GuiCtrlCreateCheckbox("Accounts",28, 120, 80, 20) $GroupExecutives = GuiCtrlCreateCheckbox("Executives",28, 140, 80, 20) $GroupVisitors = GuiCtrlCreateCheckbox("Visitors",28, 160, 80, 20) $GroupEveryone = GuiCtrlCreateCheckbox("Everyone",28, 180, 80, 20) $FolderCreation = GUICtrlCreateButton("1", 270, 150, 40, 40, $BS_ICON) GUICtrlSetImage(-1, "shell32.dll", -159) GUICtrlCreateLabel("Create Folder", 259, 195, 70, 18) GUISetState(@SW_SHOW) ; GUI MESSAGE LOOP GuiSetState() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _Exitcode() ;Create User, User Folder and Share Out Case $FolderCreation $FolderInput2 = GUICtrlRead($FolderInput) $GroupManagement2 = GUICtrlRead($GroupManagement) $GroupAccounts2 = GUICtrlRead($GroupAccounts) $GroupExecutives2 = GUICtrlRead($GroupExecutives) $GroupVisitors2 = GUICtrlRead($GroupVisitors) $GroupEveryone2 = GUICtrlRead($GroupEveryone) ;Run(@COMSPEC & " /c mkdir " & "E:\Users\" & $UsernameInput2) Run(@COMSPEC & " /c mkdir " & "D:\" & $FolderInput2) If $GroupManagement2 = 1 Then Run(@COMSPEC & " /c net localgroup Management /add " & $UsernameInput2) EndIf If $GroupAccounts2 = 1 Then Run(@COMSPEC & " /c net localgroup Accounts /add " & $UsernameInput2) EndIf If $GroupExecutives2 = 1 Then Run(@COMSPEC & " /c net localgroup Executives /add " & $UsernameInput2) EndIf If $GroupVisitors2 = 1 Then Run(@COMSPEC & " /c net localgroup Visitors /add " & $UsernameInput2) EndIf If $GroupEveryone2 = 1 Then Run(@COMSPEC & " /c net localgroup Private /add " & $UsernameInput2) EndIf Run(@COMSPEC & " /c mkdir " & "D:\Users\" & $UsernameInput2) Run(@COMSPEC & " /c net share " & $UsernameInput2 & "=D:\Users\" & $UsernameInput2 & " /grant:" & $UsernameInput2 & ",full") $ans = msgbox(4100, "New User Created", "You have successfully created a new user. Do you want to add addtional user?") Select Case $ans = 6 $var = "YES" Case $ans = 7 $var = "NO" Exit EndSelect If $ans = 6 Then GUICtrlSetData($UsernameInput, "") GUICtrlSetData($PasswordInput, "") GUICtrlSetState($GroupManagement, $GUI_UNCHECKED) GUICtrlSetState($GroupPrivate, $GUI_UNCHECKED) GUICtrlSetState($GroupAccounts, $GUI_UNCHECKED) GUICtrlSetState($GroupExecutives, $GUI_UNCHECKED) GUICtrlSetState($GroupVisitors, $GUI_UNCHECKED) EndIf EndSwitch WEnd Func _Exitcode() GUIDelete() Exit EndFunc I am not any code expert and I don't know the basic simple coding language like Java and C+. I just pick and learn and try to create something out of the norm. What I wanna do over here is to create a simple panel for the user/administrator of the server to create folder with this 5 optional permission. Problem is, via command prompt, you can't do a "net share abc=D:\abc /grant:account,full" and do another "net share abc=D:\abc /grant:visitor,full". Is there any other work around like, checking the checkbox if it's tick then do "Net share abc=D:\abc /grant:"groups",full" etc?
PsaltyDS Posted December 31, 2010 Posted December 31, 2010 (edited) What you want is SetACL. Download the command line version from SourceForge. It also has a DLL available if you know how to use that.You can set/remove perms on files, directories, shares, printers, and registry keys. The command line takes a little getting used to because it can do so many things, but it works well in batch files and AutoIt scripts. Edited December 31, 2010 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
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