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.
1 comment:
nowhere found a solution so i'll start posting my solution:
32bit:
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
Kheno
Post a Comment