Eine Alternative wäre noch:
AutoIt
#cs
_WinAPI_GetFileAttributes
Global Const $FILE_ATTRIBUTE_READONLY = 0x00000001
Global Const $FILE_ATTRIBUTE_HIDDEN = 0x00000002
Global Const $FILE_ATTRIBUTE_SYSTEM = 0x00000004
Global Const $FILE_ATTRIBUTE_DIRECTORY = 0x00000010
Global Const $FILE_ATTRIBUTE_ARCHIVE = 0x00000020
Global Const $FILE_ATTRIBUTE_DEVICE = 0x00000040
Global Const $FILE_ATTRIBUTE_NORMAL = 0x00000080
Global Const $FILE_ATTRIBUTE_TEMPORARY = 0x00000100
Global Const $FILE_ATTRIBUTE_SPARSE_FILE = 0x00000200
Global Const $FILE_ATTRIBUTE_REPARSE_POINT = 0x00000400
Global Const $FILE_ATTRIBUTE_COMPRESSED = 0x00000800
Global Const $FILE_ATTRIBUTE_OFFLINE = 0x00001000
Global Const $FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 0x00002000
Global Const $FILE_ATTRIBUTE_ENCRYPTED = 0x00004000
_WinAPI_SetFileAttributes
The file attributes to set for the file. This parameter can be one or more of the following values.
$FILE_ATTRIBUTE_READONLY
$FILE_ATTRIBUTE_HIDDEN
$FILE_ATTRIBUTE_SYSTEM
$FILE_ATTRIBUTE_ARCHIVE
$FILE_ATTRIBUTE_NORMAL
$FILE_ATTRIBUTE_TEMPORARY
$FILE_ATTRIBUTE_OFFLINE
$FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
Not all attributes are supported by this function. For more information, see MSDN library.
#ce
#include <WinAPIFiles.au3>
_PrintAttrib('c:\Users\Default\')
_PrintAttrib('c:\Users\Default User\')
_PrintAttrib('c:\Users\Default\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessibility\Magnify.lnk')
_PrintAttrib('c:\Users\Default\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessibility\Radar.lnk')
Func _GetAttrib($sPath)
Local $aAttrib = _WinAPI_GetFileAttributes($sPath)
Return SetError(@error, (BitAND($aAttrib, 0x00000010) > 0), (BitAND($aAttrib, 0x00000001) > 0))
EndFunc
Func _PrintAttrib($sPath)
Local $aAttrib = _GetAttrib($sPath)
Select
Case @error = True
ConsoleWrite('Error: Der Pfad existiert nicht!' & @CRLF)
Case @extended = True
$sPath = 'Das Verzeichnis ist '
Case Else
$sPath = 'Die Datei ist '
EndSelect
ConsoleWrite($sPath & (($aAttrib = True) ? '':'nicht ') & 'schreibgeschützt.' & @CRLF)
EndFunc
Alles anzeigen