1

I'm wondering it it is possible to retrieve the file modified date from a windows indexing search.

I'm getting the name of the file with:

objRecordset.Fields.Item("System.ItemName")

And I'm not sure how to check all the properties or fields available in objRecordset but I've found googling this ones:

SYSTEM.ITEMNAME

SYSTEM.ITEMURL

SYSTEM.FILEEXTENSION

SYSTEM.FILENAME

SYSTEM.FILEATTRIBUTES

SYSTEM.FILEOWNER

SYSTEM.ITEMTYPE

SYSTEM.ITEMTYPETEXT

SYSTEM.KINDTEXT

SYSTEM.KIND

SYSTEM.MIMETYPE

SYSTEM.SIZE

As you can see there's nothing related with the date of the file but I find it difficult to believe this is not somewhere accessible.

This is the vbs script I'm using right now:

'To run this snippet, save it to a file and run it using cscript.exe from a command line. 
'Running the .vbs file with Windows Script Host may cause dialog boxes to open for each item returned from the index.

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")

objConnection.Open "Provider=Search.CollatorDSO;Extended Properties='Application=Windows';"

objRecordSet.Open "SELECT System.ItemName FROM SYSTEMINDEX WHERE DIRECTORY='file:C:/folderIndexed' AND CONTAINS('INSULATING') ORDER BY System.ItemName DESC", objConnection

Do Until objRecordset.EOF
    Wscript.Echo objRecordset.Fields.Item("System.ItemName")
    objRecordset.MoveNext
Loop
Steve
  • 203
  • 6
  • 13

1 Answers1

2

This:

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")

objConnection.Open "Provider=Search.CollatorDSO;Extended Properties='Application=Windows';"

objRecordSet.Open "SELECT System.ItemName, System.DateModified FROM SYSTEMINDEX WHERE DIRECTORY='file:C:/usr'", objConnection

Do Until objRecordset.EOF
    Wscript.Echo objRecordset.Fields.Item("System.ItemName")
    Wscript.Echo objRecordset.Fields.Item("System.DateModified")
    objRecordset.MoveNext
Loop

Produces this output:

README.txt
31.1.2014 17:20:14
bin
29.10.2012 14:09:02
share
29.10.2012 14:09:01
docs
29.10.2012 14:09:02
etc
29.10.2012 14:09:02

This list might help also: http://msdn.microsoft.com/en-us/library/windows/desktop/ff521735%28v=vs.85%29.aspx

Dusan Bajic
  • 2,046
  • 1
  • 17
  • 20