NTFS time stamp display with 100 ns granularity

I understand that the FAT file system stores its timestamps for files (change date, etc.) with 2 second granularity, and NTFS stores them with 100 ns granularity.

I am using VBScript with FileSystemObject to display file information. The file.DateLastModified function shows me a date accurate to 1 second (in NTFS).

Is there a way to show timestamps with precision according to the internal granularity of NTFS storage. I present something like 8/9/2010 14: 40: 30,1234567

And if not with VBScript / FileSystemObject, will there be another way?

+4
source share
2 answers

File timestamps are stored as FILETIME in NTFS, but the millisecond part is not passed to DateTime Variant, so VBS does not see it. However, a WMI object can support this.

Sub PrintTimestamp(sFilename) Set oWMI = GetObject("winmgmts:!\\.\root\cimv2") Set oFiles = oWMI.ExecQuery("Select * from CIM_DataFile where Name = '" & sFilename & "'") Set oDateTime = CreateObject("WbemScripting.SWbemDateTime") For Each oFile in oFiles oDateTime.Value = oFile.LastAccessed WScript.Echo oFile.Name & " " & oDateTime.GetVarDate & " " & oDateTime.Microseconds Next End Sub PrintTimestamp("c:\\temp\\demo.vbs") 
+6
source

Full file accuracy time is easily accessible through the native Windows API. This MSDN article explains how to do this: File time .

I do not know how to read 64-bit FILETIME from VBS, especially since VBS does not process 64-bit numbers initially. However, if you have FILETIME, you can parse it with SWbemDateTime . Here is an example.

0
source

Source: https://habr.com/ru/post/1342111/


All Articles