You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Windows registry value not found - PdhUtil.ENGLISH_COUNTER_KEY #633
I have run into an issue on a Windows 7 machine while trying to get the processor information using the following code:
SystemInfo si = new SystemInfo();
si.getHardware().getProcessor();
Here are the relevant parts of the stack trace I got:
java.lang.ExceptionInInitializerError
at oshi.hardware.platform.windows.WindowsHardwareAbstractionLayer.getProcessor(WindowsHardwareAbstractionLayer.java:64)
...
Caused by: com.sun.jna.platform.win32.Win32Exception: The system cannot find the file specified.
at com.sun.jna.platform.win32.Advapi32Util.registryGetStringArray(Advapi32Util.java:800)
at com.sun.jna.platform.win32.Advapi32Util.registryGetStringArray(Advapi32Util.java:775)
at oshi.jna.platform.windows.PdhUtil.PdhLookupPerfIndexByEnglishName(PdhUtil.java:99)
at oshi.hardware.platform.windows.WindowsCentralProcessor.(WindowsCentralProcessor.java:68)
... 20 more
This machine does not have the registry value that Oshi tries to look for: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib\009\Counter.
The OS is in English, and the expected value exists in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib\CurrentLanguage. Ps. All the machines I could get my hands on had the Counter value in this particular key (Windows 7 and Windows 10).
I was wondering if there is any particular reason to look for the key 009. I believe that machines running in different languages would have the same problem.
According to Microsoft Docs, registry information should always be installed in that 009 key. However, I have noticed in my testing that occasionally that key is deleted on English Windows installs when it duplicates the CurrentLanguage, typically if the user has manipulated language settings.
I believe this represents registry corruption and should be fixed using the lodctr /R command provided in the above link. However, OSHI should probably notify the user of the corruption (and how to fix it) or shouldn't be hard to have OSHI just check "CurrentLanguage" as a backup if 009 results in the exception you see.
Also, to be clear: Performance Counters in localized versions of windows will have both the localized language (e.g., French is 012) and in English (009) for programming consistency. This is what OSHI relies upon as the standard. See here:
HKEY_LOCAL_MACHINE
\SOFTWARE
\Microsoft
\Windows NT
\CurrentVersion
\Perflib
Last Counter = highest counter index
Last Help = highest help index
\009
Counters = 2 System 4 Memory...
Help = 3 The System Object Type...
\supported language, other than English
Counters = ...
Help = ...
Activity
dbwiddis commentedon Sep 27, 2018
According to Microsoft Docs, registry information should always be installed in that 009 key. However, I have noticed in my testing that occasionally that key is deleted on English Windows installs when it duplicates the CurrentLanguage, typically if the user has manipulated language settings.
I believe this represents registry corruption and should be fixed using the
lodctr /Rcommand provided in the above link. However, OSHI should probably notify the user of the corruption (and how to fix it) or shouldn't be hard to have OSHI just check "CurrentLanguage" as a backup if 009 results in the exception you see.dbwiddis commentedon Sep 27, 2018
Also, to be clear: Performance Counters in localized versions of windows will have both the localized language (e.g., French is 012) and in English (009) for programming consistency. This is what OSHI relies upon as the standard. See here: