IronPython: Querying Windows Desktop Search

I needed to find some files without restoring to the desktop search UI – this IronPython script implements a very simple search that uses System.Data.OleDb* to query the Windows Desktop Search catalog




import clr
import System

import System.Data

wds_connection_string = “Provider=Search.CollatorDSO;Extended Properties=’Application=Windows’;”
wds_query = “SELECT System.FileName FROM SYSTEMINDEX”
wds_connection = System.Data.OleDb.OleDbConnection( wds_connection_string )
wds_connection.Open( )
wds_command = System.Data.OleDb.OleDbCommand( wds_query , wds_connection)
wds_results = wds_command.ExecuteReader()

while ( wds_results.Read() ) :
print wds_results.GetString(0)
n +=1
if ( n>= max_results_to_show) : break


For Example

You can directly paste the code into the IronPython console to see the results…


For more information

Microsoft TechNet: “Seek and Ye Shall Find : Scripting Windows Desktop Search 3.”0

Microsoft Windows Search 3.x SDK

NOTE: You don’t need to download the SDK to run the sample code.

Comments (0)

Skip to main content