File Attributes

上一篇 / 下一篇  2010-03-31 00:11:03 / 个人分类:VBScript

Table 6-3. File attributes and bitmask values

Attribute

Bitmask value

Meaning

Normal

0

No attributes set

Read-only

1

File can be read but not changed

Hidden

2

File cannot be seen in default view of Microsoft Windows Explorer

System

4

File is used by the operating system (OS)

Archive

32

File changed since last backup

Alias

64

File is a shortcut to another file

Compressed

2048

File has been compressed

 

 

FileAttributes.vbs

Option Explicit
On Error Resume Next
Dim objFSO
Dim objFile
Dim Target

Target = "C:\fso\test.txt"
Set bjFSO = CreateObject("Scripting.FileSystemObject")
Set bjFile = objFSO.GetFile(Target)

WScript.Echo "The file is: " & target
WScript.Echo "bitmap number is: " & objFile.Attributes & _
   " " & funAttrib(objFile.attributes)


Function funAttrib(intMask)
Dim strAttrib
If IntMask = 0 Then strAttrib = "No attributes"
If intMask And 1 Then strAttrib = strAttrib & "Read Only, "
If intMask And 2 Then strAttrib = strAttrib & "Hidden, "
If intMask And 4 Then strAttrib = strAttrib & "System, "
If intMask And 8 Then strAttrib = strAttrib & "Volume, "
If intMask And 16 Then strAttrib = strAttrib & "Directory, "
If intMask And 32 Then strAttrib = strAttrib & "Archive, "
If intMask And 64 Then strAttrib = strAttrib & "Alias, "
If intMask And 2048 Then strAttrib = strAttrib & "Compressed, "
funAttrib = strAttrib
End Function

TAG:

 

评分:0

我来说两句

Open Toolbar