Question

I'd like to determine how to programatically start/stop/pause the indexer from Microsoft Search.

I know it is possible because I've seen it done in programs like this one: http://brandontools.com/files/folders/sidebar_gadgets/entry511.aspx

However, I cannot find any docs on MSDN or anywhere.

There is a "Windows Search" service which can be controlled with traditional service control methods. However, starting/stopping this service also changes the availability of search itself. I want to control just the indexer.

Does anyone know where docs may be found that describe how to interact with the indexer? My search skills have failed me.

Was it helpful?

Solution

There isn't a way to simply disable the indexing part. It's an all or nothing service. The description of the WSearch service states:

"Provides content indexing and property caching for file, email and other content (via extensibility APIs). The service responds to file and email notifications to index modified content. If the service is stopped or disabled, the Explorer will not be able to display virtual folder views of items, and search in the Explorer will fall back to item-by-item slow search."

However, you might be able to control it through drive/folder properties ... from Explorer, you can switch it of for an individual drive (see the properties of a drive; there's an option "allow indexing service..."), or for a folder (folder properties -> advanced -> "For fast searching, allow indexing service...").

EDIT ... a bit of googling, and the above properties are available - if you look at the MSDN page for System.IO.FileAttributes, there's a property NotContentIndexed with the description The file will not be indexed by the operating system's content indexing service. I would assume that you should be able to set this on individual folders. I don't know if this works if set at the drive level (without a recursive run through the drive), but hopefully it'll give you a head-start on whatever you're ultimately trying to achieve.

OTHER TIPS

According the Microsoft there isn't an official way of doing so.

Something like this:

ServiceController service = new ServiceController("WSearch");

service.Start();

or

service.Stop();

Here is a great tutorial on programmatically interacting with Windows Search: article at JoyOfCode.

The Windows Search 3.x SDK provides a .NET API that works against Windows Search 3 or 4.

Unfortunately, it doesn't expose pause/resume. All of the index control samples I have found use WMI to stop the search service. That will stop indexing, obviously, but at the expense of search itself not being available.

It's an old thread, but I ran across it. Someone else might as well.

Use an AutoIT script to open the Indexing Options and click the Pause button in the dialog box.

Open the "Run" Dialog (Start | Run), type(or copy) %SystemRoot%\system32\compmgmt.msc /s and unfold the last one

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top