COM Object: Scripting.FileSystemObject
Purpose: Retrieves file & folder properties.
System Requirements: General
Documentation Link: FileSystemObject
DateLastAccessed Property, DateCreated Property, DateLastModified Property
Size Property
Name Property
Shortname Property
Type property
Attributes Property
Path Property
Shortpath Property
Basic Code Example - this example demonstrates how to retrieve the properties of a specified file and folder via FileSystemObject:
Code: Select all
filepath := "C:\Windows\System32\notepad.exe" ;set the target's full file path
folderpath := "C:\Windows\System32" ;set the target's full folder path
objFSO := ComObjCreate("Scripting.FileSystemObject")
ComObjError(false) ;disable COM error messages for some non available properties
objFile := objFSO.GetFile(filepath)
objFolder := objFSO.GetFolder(folderpath)
FileProperties := "Date Created:`t`t" . objFile.DateCreated . "`n"
. "Last Accessed:`t`t" . objFile.DateLastAccessed . "`n"
. "Last Modified:`t`t" . objFile.DateLastModified . "`n"
. "File Size(bytes):`t`t" . objFile.Size . "`n"
. "File Name:`t`t" . objFile.Name . "`n"
. "File Short Name:`t`t" . objFile.ShortName . "`n"
. "File Type:`t`t`t" . objFile.Type . "`n"
;Attributes 0: Normal 1:ReadOnly 2:Hidden 4:System 8:Volume 16:Directroy 32:Archive 1024:Alias 2048:Compressed
. "Attributes:`t`t`t" . objFile.attributes . "`n"
. "File Path:`t`t`t" . objFile.Path . "`n"
. "File Short Path:`t`t" . objFile.ShortPath . "`n"
FolderProperties := "Date Created:`t`t" . objFolder.DateCreated . "`n"
. "Last Accessed:`t`t" . objFolder.DateLastAccessed . "`n"
. "Last Modified:`t`t" . objFolder.DateLastModified . "`n"
. "Size(bytes):`t`t" . objFolder.Size . "`n"
. "Folder Name:`t`t" . objFolder.Name . "`n"
. "Folder Short Name:`t`t" . objFolder.ShortName . "`n"
. "Folder Type:`t`t" . objFolder.Type . "`n"
. "Attributes:`t`t`t" . objFolder.attributes . "`n"
. "Folder Path:`t`t" . objFolder.Path . "`n"
. "Folder Short Path:`t`t" . objFolder.ShortPath
ComObjError(true)
msgbox % FileProperties
msgbox % FolderProperties