5

我想确定如何从 Microsoft Search 以编程方式启动/停止/暂停索引器。

我知道这是可能的,因为我在这样的程序中看到过它:http: //brandontools.com/files/folders/sidebar_gadgets/entry511.aspx

但是,我在 MSDN 或任何地方都找不到任何文档。

有一个“Windows Search”服务,可以用传统的服务控制方法来控制。但是,启动/停止此服务也会改变搜索本身的可用性。我只想控制索引器。

有谁知道在哪里可以找到描述如何与索引器交互的文档?我的搜索技巧让我失望了。

4

6 回答 6

3

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

于 2009-10-25T20:16:24.290 回答
3

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.

于 2009-10-25T20:20:21.370 回答
0

这是关于以编程方式与 Windows Search 交互的精彩教程:JoyOfCode 上的文章

Windows Search 3.x SDK提供了一个适用于 Windows Search 3 或 4的.NET API。

不幸的是,它没有公开暂停/恢复。我发现的所有索引控制示例都使用 WMI 来停止搜索服务。显然,这将停止索引,但代价是搜索本身不可用。

于 2010-01-28T12:38:23.240 回答
0

这是一个旧线程,但我遇到了它。别人也可以。

使用 AutoIT 脚本打开索引选项并单击对话框中的暂停按钮。

于 2013-12-27T20:12:23.343 回答
-1

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

于 2009-10-25T20:25:16.943 回答
-1

像这样的东西:

ServiceController service = new ServiceController("WSearch");

服务.开始();

或者

服务.停止();

于 2009-10-25T19:18:00.137 回答