Windows-Server-2008

從 Windows 索引搜尋中獲取修改日期

  • February 3, 2014

我想知道是否可以從 Windows 索引搜尋中檢索文件修改日期。

我正在獲取文件的名稱:

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

而且我不確定如何檢查所有可用的屬性或欄位,objRecordset但我發現Google搜尋這些:

SYSTEM.ITEMNAME

SYSTEM.ITEMURL

系統文件擴展

系統文件名

系統文件屬性

系統文件所有者

SYSTEM.ITEMTYPE

SYSTEM.ITEMTYPETEXT

SYSTEM.KINDTEXT

系統類型

系統.MIMETYPE

系統尺寸

如您所見,與文件日期沒有任何關係,但我很難相信這不是可以訪問的地方。

這是vbs我現在正在使用的腳本:

'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

這:

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

產生這個輸出:

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

此列表可能也有幫助:http: //msdn.microsoft.com/en-us/library/windows/desktop/ff521735%28v=vs.85%29.aspx

引用自:https://serverfault.com/questions/571315