More About Files
You can use a CIM_DataFile to find out a lot more about the file it represents than merely the size, attributes, and access times. It can also reveal whether the file has been compressed (and, if so, with what algorithm) and whether it has been encrypted (and, if so, using what method). It can also show what the filename would look like under DOS (that is, the 8.3 filename), and it can reveal the file type (as defined by file associations), the path, and even whether the user querying the CIM_DataFile can read and write to the file in question. The following script uses these facilities to give a more encyclopedic insight into the boot.ini file on a system. It also includes the GetVBDate() function just discussed:
'file_info.vbs - print out information about boot.ini Set refFile = GetObject("winMgmts:CIM_DataFile.Name='c:\boot.ini'") WScript.echo "Information about " & refFile.Name With refFile WScript.echo "Name: " & .Name WScript.echo "Size: " & .FileSize WScript.echo "Created on " & GetVBDate(.CreationDate) WScript.echo "Last modified on " & GetVBDate(.LastModified) WScript.echo "Last accessed on " & GetVBDate(.LastAccessed) WScript.echo "Short filename: " & .EightDotThreeFileName WScript.echo "Filetype: " & .FileType WScript.echo "Extension: " & .Extension WScript.echo "Path: " & .Path WScript.echo "Drive: " & .Drive If .Archive then WScript.echo "Archive bit set" If .Hidden then WScript.echo "File is hidden" If .System then WScript.echo "System File" If .Compressed then WScript.echo "Compressed with " & .CompressionMethod If .Encrypted then WScript.echo "Encrypted with " & .EncryptionMethod If .Readable then WScript.echo "You may read this file" Else WScript.echo "You may not read this file." End If If .Writeable then WScript.echo "You may write to this file" Else WScript.echo "You may not write to this file" End If End With Set refFile = Nothing 'Don't forget to include this function... Function GetVBDate(wd) GetVBDate = DateSerial(left(wd,4),mid(wd,5,2),mid(wd,7,2)) _ + TimeSerial(mid(wd,9,2),mid(wd,11,2),mid(wd,13,2)) End Function
Running this script on a system gives you a very good idea of boot.ini's vital statistics!