VBS中如何用FSO改变文件的属性?比如说给文件加上只读属性?

来源:百度知道 编辑:UC知道 时间:2024/06/07 07:05:53

set fso=createobject("scripting.filesystemobject")
set f=fso.getfile("[文件路径,不加中括号]")
if not f.attributes and 1 then
f.attributes=f.attributes+1
end if

obj.attributes=?

右边用数字来表示,如:
Normal 0 普通文件。没有设置任何属性。
ReadOnly 1 只读文件。可读写。
Hidden 2 隐藏文件。可读写。
System 4 系统文件。可读写。
Directory 16 文件夹或目录。只读。
Archive 32 上次备份后已更改的文件。可读写。
Alias 1024 链接或快捷方式。只读。
Compressed 2048 压缩文件。只读。

如果相应用多种属性,只须把它们的值加起来.