Search code examples
vb.netwindowsindexingrebuild

Is it possible to use vb.net to rebuild the Windows search index on another machine on a network?


Has anyone found a way using vb.net to rebuild the Windows index on another machine remotely? I know it can be done using the 'Indexing Options' in Control Panel, but not sure if there is a function or setting that can be called to trigger this via VB. Any thoughts/ideas/hacks are welcome.

Regards


Solution

  • I found that by changing the registry to think it failed to update the index prompts Windows to re-index on reboot. This can be done remotely by passing in the computer name you want to rebuild.

    Dim MyRegistry As Microsoft.Win32.RegistryKey Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(Microsoft.Win32.RegistryHive.CurrentUser, [SomeComputerName])
    Dim myRegKey = MyRegistry.OpenSubKey("Software\Microsoft\Windows Search", True)
    
    myRegKey.SetValue("SetupCompletedSuccessfully", 0)
    

    Hope this helps someone else!