Sets attributes of a file or directory.

setfileattr <filename> <attributes>


string <filename>
The file name or directory name
integer <attributes>
A user can specify a attribute value combined in the following:
Value Meaning
$1 Read only
$2 Hidden
$4 The operating system uses a part of, or uses exclusively
$20 Archive
$80 Not have other attributes set
Enabled when the value is independently specified.
$100 Temporary
$1000 Physically moved to offline storage(Windows 2000 or later)
$2000 Not to be indexed by the content indexing service(Windows 2000 or later)

Return Value

System variable <result>
When the command fails, 0 is stored.
When the command succeeds, 1 is stored.


; add readonly attribute
file = 'c:\test.txt'
getfileattr file
attr = result | $1 ; keep current attributes
setfileattr file attr

See also