Rebuilding faulty performance counters with LODCTR.exe.
- Open a command prompt as Administrator on the affected machine.
- In the Application event log, identify the faulty service name in the event text. Note in event 1008, the performance counter DLL file path is listed in full - you can skip directly to step 4.
- Identify the performance counter DLL path, with
LODCTR /Q:<ServiceName>
. (Most of the dlls are in %systemroot%\system32, but others - like the .Net counter dlls - are in their own directory.) Put quotes around the service name if it has spaces. Run the following command and copy the Dll Name: path. C:>lodctr /q:".NET Data Provider for SqlServer"
Performance Counter ID Queries [PERFLIB]:
Base Index: 0x00000737 (1847)
Last Counter Text ID: 0x00002CB8 (11448)
Last Help Text ID: 0x00002CB9 (11449)
[.NET Data Provider for SqlServer] Performance Counters (Enabled)
DLL Name: %systemroot%\system32\netfxperf.dll
Open Procedure: OpenPerformanceData
Collect Procedure: CollectPerformanceData
Close Procedure: ClosePerformanceData - Rebuild the counter from the dll with
LODCTR /R <dllPath>
- with any luck, it'll successfully rebuild the counter settings. C:>lodctr /r %systemroot%\system32\netfxperf.dll
Info: Successfully rebuilt performance counter setting from system backup store
If the above completes successfully, check that the application event log shows no further errors and you're done.
----------
If LODCTR /R throws an error, the counter needs to be rebuilt from its INI files. E.g.:
C:\>lodctr /r %systemroot%\system32\bitsperf.dll
Error: Unable to rebuild performance counter setting from system backup store, error code is 2
Rebuilding the performance counters from the INI files can take a bit longer, depending on how many there are. To identify the INI files and rebuild the counters:
- Query the registry under
HKLM\SYSTEM\CurrentControlSet\Services\<ServiceName>\Performance
. The performance counter INI file name is listed in the PerfIniFile value. C:>reg query HKLM\SYSTEM\CurrentControlSet\Services\BITS\Performance /v PerfIniFile
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\BITS\Performance
PerfIniFile REG_SZ bitsctrs.ini - Locate the matching INI file(s) in the
C:\Windows\INF\<ServiceName>
directory. Don't forget the*
in front of the INI file name when searching from the <ServiceName> parent directory (since the INIs are generally in one or more subdirectories). C:>dir /b /s C:\Windows\INF\bits*bitsctrs.ini
C:\Windows\INF\bits\0000\bitsctrs.ini
C:\Windows\INF\bits\0409\bitsctrs.ini - Run
LODCTR /R <inipath>
on each of the INI files found in the service subdirectories. Make sure you have the correct full path for each INI. C:>lodctr /r C:\Windows\INF\bits\0000\bitsctrs.ini
Info: Successfully rebuilt performance counter setting from system backup store C:>lodctr /r C:\Windows\INF\bits\0409\bitsctrs.ini
Info: Successfully rebuilt performance counter setting from system backup store
Alternatively, for step 3, you can use a one-line command to rebuild from all the matching counter INIs in the subdirectories under the parent service path.
E.g.: FOR /R C:\Windows\INF\<ServiceName>\ %I IN (*bitsctrs.ini) DO lodctr /r %I
C:\>FOR /R C:\Windows\INF\bits\ %I IN (*bitsctrs.ini) DO lodctr /r %I
C:\>lodctr /r C:\Windows\INF\bits\0000\bitsctrs.ini
Info: Successfully rebuilt performance counter setting from system backup store
C:\>lodctr /r C:\Windows\INF\bits\0409\bitsctrs.ini
Info: Successfully rebuilt performance counter setting from system backup store
If you want to check the correct file names are found in the previous command without executing lodctr, replace lodctr /r
in the command line with echo
. This should output the same paths for each INI file as the DIR command earlier:
FOR /R C:\Windows\INF\bits\ %I IN (*bitsctrs.ini) DO echo %I
After rebuilding the counter from the INIs completes successfully, check that there are no further errors in the Application Log.