RegRead and Error -2147024894

Error -2147024894 appears when you use the WScript.Shell RegRead object to read a registry key that does not exist. But why would you get this error when the key does exist!

Probably because you are running your code inside a HTA and using a 64bit operating system.

The HTA environment is mshta, which is 32 bit. This means that when your code reads registry entries such as HKLM\Software\Microsoft\Windows via a HTA on a 64bit OS it is really reading HKLM\Software\Wow6432Node\Microsoft\Windows. Therefore if you have values or keys at HKLM\Software\Microsoft\Windows and not at HKLM\Software\Wow6432Node\Microsoft\Windows then you will get error -2147024894 because the value/key cannot be found.

Run the HTA on a 32bit OS and it work fine. But most confusing is that if you take the code from the HTA script and save it to a .vbs or .js file and run it (on the 64bit OS) via wscript or cscript then the script will find the registry key at HKLM\Software\Microsoft\Windows because in this instance the wscript or cscript environment is 64bit.

Of course this is true for any HKLM\Software registry entry.






One response to “RegRead and Error -2147024894”

  1. nico avatar

    nowhere found a solution so i’ll start posting my solution:

    C:\Windows\SysWOW64\mshta.exe “C:\install.hta” %*

    64bit (now all reg keys are accessible)
    C:\Windows\System32\mshta.exe “C:\install.hta” %*

    hope it helps others


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.