radiererer 0 Posted May 15, 2011 Hi, I'm looking for a possibility to check the accessibility of a folder. Unfortunately I can't use FileExists() for that, because there is no general subfolder or file in the folders, which I want to check. Furthermore I tried FileGetAttrib() but I only get D as output (naturally). Thanks a lot in advance. Share this post Link to post Share on other sites
wakillon 403 Posted May 15, 2011 FileExists works for folder too ! AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Share this post Link to post Share on other sites
radiererer 0 Posted May 15, 2011 (edited) I know, but I also get a 1 as return value even though there is no permission to open/access the folder. Edited May 15, 2011 by radiererer Share this post Link to post Share on other sites
wakillon 403 Posted May 15, 2011 For see Access Control List, see this AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Share this post Link to post Share on other sites
wakillon 403 Posted May 15, 2011 Another way to get perms : #cs ---------------------------------------------------------------------------- Get Acl By Cacls R Read C Change (write) F Full control P Change Permissions (Special access) O Take Ownership (Special access) X EXecute (Special access) E REad (Special access) W Write (Special access) D Delete (Special access) T Not Specified (OI) = Object Inherit. ( Files (objects) created in this folder inherit its permissions ) (CI) = Container Inherit. ( Directories (containers) created in this folder inherit its permissions ) (IO) = Inherit Only. ( The permission does not apply to the directory, but only its subdirectories ) #ce ---------------------------------------------------------------------------- $_CaclsPath = @SystemDir & "\CACLS.exe" _GetAclByCacls ( @MyDocumentsDir ) Func _GetAclByCacls ( $_FilePath ) $_Run = FileGetShortName ( $_CaclsPath ) & ' "' & $_FilePath & '"' ConsoleWrite ( '--------- $_Run : ' & $_Run & @Crlf ) $_Pid = Run ( $_Run, '', @SW_HIDE, 4 ) Local $_StdoutRead='' While ProcessExists ( $_Pid ) $_StdoutRead = StringStripWS ( StdoutRead ( $_Pid ), 7 ) If Not @error And $_StdoutRead <> '' Then _ ConsoleWrite ( "-->-- STDOUT read : " & @CRLF & $_StdoutRead & @Crlf ) Wend EndFunc ;==> _GetAclByCacls ( ) AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Share this post Link to post Share on other sites
radiererer 0 Posted May 15, 2011 Another way to get perms : #cs ---------------------------------------------------------------------------- Get Acl By Cacls R Read C Change (write) F Full control P Change Permissions (Special access) O Take Ownership (Special access) X EXecute (Special access) E REad (Special access) W Write (Special access) D Delete (Special access) T Not Specified (OI) = Object Inherit. ( Files (objects) created in this folder inherit its permissions ) (CI) = Container Inherit. ( Directories (containers) created in this folder inherit its permissions ) (IO) = Inherit Only. ( The permission does not apply to the directory, but only its subdirectories ) #ce ---------------------------------------------------------------------------- $_CaclsPath = @SystemDir & "\CACLS.exe" _GetAclByCacls ( @MyDocumentsDir ) Func _GetAclByCacls ( $_FilePath ) $_Run = FileGetShortName ( $_CaclsPath ) & ' "' & $_FilePath & '"' ConsoleWrite ( '--------- $_Run : ' & $_Run & @Crlf ) $_Pid = Run ( $_Run, '', @SW_HIDE, 4 ) Local $_StdoutRead='' While ProcessExists ( $_Pid ) $_StdoutRead = StringStripWS ( StdoutRead ( $_Pid ), 7 ) If Not @error And $_StdoutRead <> '' Then _ ConsoleWrite ( "-->-- STDOUT read : " & @CRLF & $_StdoutRead & @Crlf ) Wend EndFunc ;==> _GetAclByCacls ( ) That's much easier und more understandable for a noob like me. Thanks a lot! Share this post Link to post Share on other sites
KaFu 296 Posted May 15, 2011 (edited) How about something like this ? $sPath = @ScriptDir ConsoleWrite(_Directory_Is_Accessible($sPath) & @CRLF) $sPath = "C:\Windows\System32\appmgmt\MACHINE\" ConsoleWrite(_Directory_Is_Accessible($sPath) & @CRLF) Func _Directory_Is_Accessible($sPath) If Not StringInStr(FileGetAttrib($sPath), "D", 2) Then Return SetError(1, 0, 0) Local $iEnum = 0 While FileExists($sPath & "\_test_" & $iEnum) $iEnum += 1 WEnd Local $iSuccess = DirCreate($sPath & "\_test_" & $iEnum) Switch $iSuccess Case 1 DirRemove($sPath & "\_test_" & $iEnum) Return True Case Else Return False EndSwitch EndFunc ;==>_Directory_Is_Assesible Edited May 15, 2011 by KaFu OS: Win10-1909 - 64bit - German, AutoIt Version: 3.3.14.5, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2019-Dec-21) BIC - Batch-Image-Cropper (2019-Dec-11) COP - Color Picker (2009-May-21) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2019-Dec-07) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Share this post Link to post Share on other sites