Previous Page
Next Page

File Properties

Name and Size are just two file properties that can be obtained by using FileSystemObject. A file property describes aspects of the file such as when it was created, when it was last accessed, when it was modified, its path, its size, and its type. The intrepid network administrator can enumerate various file properties, which can be used for both security purposes and user data management. For example, as shown in the following code, you can add a couple of lines to the ListFiles.vbs script to retrieve additional datain this case, the date the file was created and the date it was last modified. The VbTab constant is added to make the output easier to read. The completed script is saved as \My Documents\Microsoft Press\VBScriptSBS\ch06\ListFilesExtProperties.vbs. Here are the additional lines:

 WScript.Echo VbTab & "created: " & objFile.DateCreated
 WScript.Echo VbTab & "modified: " & objFile.DateLastModified

Additional file object properties can be retrieved in the same manner. All are listed in Table 6-2.

Table 6-2. File properties

Property

Use

Attributes

Bitmask representation of the file attributes such as read-only and hidden.

DateCreated

Date the file was created.

DateLastAccessed

Date the file was last accessed.

DateLastModified

Date the file was last modified.

Drive

The drive letter representing where the file is stored, followed by a colon (for example, C:).

Name

The name of the file, not including the path information (for example, ListFiles.vbs). The name does include the extension.

ParentFolder

The folder in which the file is located (not including subfolders). For example, the parent folder of C:\windows\system32\logfile.txt is Windows.

Path

The full path of the file (for example, C:\windows\system32\logfile.txt).

ShortName

8.3 (MS-DOS format) version of the file name. For example, MyLongFileName.txt might become MyLong~1.txt.

ShortPath

8.3 (MS-DOS style) version of the path. For example, C:\MyLongPath\MyLongFileName.txt might become C:\MyLong~1\MyLong~1.txt.

Size

The size of the file in bytes.

Type

The type of file as recorded in the registry. For example, a .doc file is listed as a Microsoft Word document.



Previous Page
Next Page