How to Relocate Windows Search Index Database (windows.edb) to Another Drive Programmatically


3 views

When attempting to move the Windows Search index database (typically windows.edb) to a different drive, many administrators encounter situations where the changes don't persist after service restart. The core challenge lies in Windows Search Service's registry dependencies and proper service reinitialization.

Here's the definitive method that works for Windows Server 2003 and later versions:

REM 1. Stop all related services
net stop "Windows Search"
net stop "Indexing Service"

REM 2. Create new directory structure
mkdir "D:\IndexService\Data\Applications\Windows"

For programmatic control, modify these registry keys (backup first!):

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Search]
"DataDirectory"="D:\\IndexService\\Data"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Search\Gathering Manager]
"IndexDirectory"="D:\\IndexService\\Data\\Applications\\Windows"

After registry changes, perform these file operations:

xcopy "C:\Documents and Settings\All Users\Application Data\Microsoft\Search\*.*" "D:\IndexService\Search\" /E /H /K /O /X
robocopy "C:\ProgramData\Microsoft\Search\Data" "D:\IndexService\Data" /MIR /ZB /R:3 /W:5

Complete the migration with these PowerShell commands:

# Reset Windows Search components
$searchService = Get-Service -Name "WSearch"
$searchService.Stop()
Remove-Item "C:\ProgramData\Microsoft\Search\Data\Applications\Windows\*.edb" -Force
$searchService.Start()

Create this VBScript to verify the new location:

Set objShell = CreateObject("WScript.Shell")
indexPath = objShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows Search\Gathering Manager\IndexDirectory")
WScript.Echo "Current index location: " & indexPath

After migrating Windows Search and Index Service databases from C: to D:\IndexService on our Windows Server 2003 system, we discovered the windows.edb file continues updating at its original location despite service restarts. Here's a technical deep dive into solving this.

Windows Search utilizes two distinct components:

1. Indexing Service (cisvc.exe) - Legacy service
2. Windows Search (WSearch) - Modern replacement

Both services maintain their own configuration registries that must be modified:

Here's the step-by-step solution that worked in our production environment:

@echo off
:: Stop all related services
net stop "Windows Search"
net stop "Indexing Service"

:: Copy files with proper permissions
robocopy "C:\Documents and Settings\All Users\Application Data\Microsoft\Search" "D:\IndexService\Search" /MIR /ZB /R:1 /W:1

:: Registry modifications
reg add "HKLM\SOFTWARE\Microsoft\Windows Search" /v DataDirectory /t REG_SZ /d "D:\IndexService\Search\Data" /f
reg add "HKLM\SYSTEM\CurrentControlSet\Services\cisvc" /v ImagePath /t REG_EXPAND_SZ /d "%%SystemRoot%%\system32\cisvc.exe -d D:\IndexService" /f

:: Update Windows Search configuration
%SystemRoot%\system32\rundll32.exe advapi32.dll,ProcessIdleTasks

:: Restart services
net start "Indexing Service"
net start "Windows Search"
Windows Search:
HKLM\SOFTWARE\Microsoft\Windows Search\DataDirectory

Indexing Service:
HKLM\SYSTEM\CurrentControlSet\Services\cisvc\Parameters\
    "CatalogDirectory" = "D:\IndexService"
    "WorkingDirectory" = "D:\IndexService"

After implementation:

  1. Check active file handles with Process Monitor
  2. Verify registry values with REG QUERY commands
  3. Monitor new file creation timestamps in target directory

For temporary solutions, consider NTFS junction points:

mklink /J "C:\Documents and Settings\All Users\Application Data\Microsoft\Search" "D:\IndexService\Search"

This maintains compatibility while physically storing files elsewhere.

  • Service account permissions on target directory
  • Antivirus software locking database files
  • Registry virtualization in 32-bit apps on 64-bit OS
  • Pending file operations requiring reboot