ioliver Posted February 16, 2005 Share Posted February 16, 2005 Ok, here's my code: expandcollapse popup#Include <GUIConstants.au3> $User = "User" Dim $UsersList GUICreate("File & Folder Security (CACLS)", 300, 350) $cboFF = GUICtrlCreateCombo("<Enter Path to File or Folder>", 10, 10, 280) GUICtrlCreateLabel("Group or User Names:", 10, 40) $lbxUsers = GUICtrlCreateList("<Group or User Names>", 10, 55, 280, 100) $grpUserPerm = GUICtrlCreateGroup("Permissions for " & $User, 10, 155, 280, 150) $chkN = GUICtrlCreateCheckbox("N - None", 20, 175) $chkR = GUICtrlCreateCheckbox("R - Read", 20, 190) $chkW = GUICtrlCreateCheckbox("W - Write", 20, 205) $chkC = GUICtrlCreateCheckbox("C - Change", 20, 220) $chkF = GUICtrlCreateCheckbox("F - Full Control", 20, 235) $butUpdate = GUICtrlCreateButton("Update", 20, 255) GUISetState (@SW_SHOW) ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $butUpdate $folder = GUICtrlRead($cboFF) $intfolder = StringLen($folder) $intfolder1 = $intfolder + 1 ;$caclsresult = "Key:" & @CR & "(CI) - Container Inherit" & @CR & "(OI) - Object Inherit" &_ ;@CR & "(IO) - Inherit Only" & @CR & "----------" & @CR & "" RunWait(@comspec & ' /c ' & 'cacls ' & '"' & $folder & '"' & ' > c:\cacls.txt', '', @SW_HIDE) $caclstxt = FileOpen("c:\cacls.txt", 0) While 1 $line2notexist = "False" $line = FileReadLine($caclstxt) If @error = -1 Then ExitLoop $line = StringTrimLeft($line, $intfolder1) $line = StringStripWS($line, 1); 1 = Strip Leading Whitespace $line = StringSplit($line, ":") If @error = 1 Then $line2notexist = "True" ;MsgBox(0, "Line[1] read:", $line[1]) If $line2notexist = "False" Then ;MsgBox(0, "Line[2] read:", $line[2]) If StringInStr($line[2], "special access") Then $line[2] = $line[2] & ":)" Else $line[2] = StringStripWS($line[2], 2); 2 = Strip Trailing Whitespace Select Case StringRight($line[2], 1) = "N" $line[2] = "None" Case StringRight($line[2], 1) = "R" $line[2] = "Read" Case StringRight($line[2], 1) = "W" $line[2] = "Write" Case StringRight($line[2], 1) = "C" $line[2] = "Change" Case StringRight($line[2], 1) = "F" $line[2] = "Full Control" EndSelect EndIf ;MsgBox(0, "Line[2] read:", $line[2]) EndIf If $line2notexist = "False" Then If StringLen($line[1]) < 15 Then $UsersList = $UsersList & $line[1] & "|" ;$caclsresult = $caclsresult & $line[1] & @TAB & @TAB & $line[2] & @CR Else $UsersList = $UsersList & $line[1] & "|" ;$caclsresult = $caclsresult & $line[1] & @TAB & $line[2] & @CR EndIf Else $UsersList = $UsersList & $line[1] & "|" ;$caclsresult = $caclsresult & $line[1] & @CR EndIf Wend FileClose($caclstxt) MsgBox(0, "Users List:", $UsersList) GUICtrlSetData($lbxUsers, $UsersList) ;MsgBox(0, "CACLS Results for " & $folder, $caclsresult) EndSelect If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend If you look at the part: FileClose($caclstxt) MsgBox(0, "Users List:", $UsersList) GUICtrlSetData($lbxUsers, $UsersList) There's some duplicate data is the $UsersList variable that I pass to my ListBox, but in the variable the data is in no particular order. However, when it's placed in the List Box it appears to be sorted. Is this supposed to happen? How can I prevent this from happening? Also, There is blank space in the ListBox after the data is added. How can I remove the blank space? Please let me know if you need more information. Thanks for your time, Ian "Blessed be the name of the Lord" - Job 1:21Check out Search IMF Link to comment Share on other sites More sharing options...
Holger Posted February 16, 2005 Share Posted February 16, 2005 Hi remove easily the last "|" from the $userslist with i.e. StringTrimRight. If you don't want listbox sorting you have to create a listbox with your own styles: Like in the helpfile described these are the default styles: $LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY So then take only i.e: $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY Old project:GUI/Tray menu with icons and colors Other old stuff:IconFileScanner, TriState/ThreeState GUI TreeView, GUI ContextMenu created out of a TreeView 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