0
Is it possible to override the value of an arbitrary Windows registry key for a specific application lifecycle?
My hope is that a temporary registry value can be set with the command line, so that I can combine it with the following batch-y temporary environment variable change (to point to the 1.7 JDK). C:\Windows\System32\cmd.exe /c "SET JAVA_HOME=C:\Program Files\Java\jdk1.7.0_75&& START /D ^"C:\Path\To\^" SpecialSnowflake.exe"
Situation Specific Details:
I'm using a program that requires a JDK (so I've kind of already lost). The quality of the programming is dubious. I have speculated over the relevant events in Process Monitor and pieced together a probable timeline. These details don't seem relevant to the task of temporarily overriding a registry value, but here they are, just in case:
When the program tries to pick and start the correct version of java.exe, it checks the registry path
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\java.exe
. Presumably, the program expects this bizarre-looking key to point to the most current version of Java (why not use the Path and/or JAVA_HOME vars?), however, this strange key does not exist on any of my PCs. Since the key is not found, the program uses a likely hardcoded default path for Java, which turns out to be %windir%\SysWOW64\java.exe. That particular java.exe has not been touched by any of the 1.8 JRE/JDK installers, and thus remains outdated at 1.7 on my PCs. This 1.7 java.exe is launched. It checks the keyHKLM\SOFTWARE\Wow6432Node\JavaSoft\Java Runtime Environment\CurrentVersion
, reads 1.8, and terminates itself. The troublesome program in question notices this, reports that the key is 1.8, but should be 1.7, and helpfully provides the wrong registry path to a key that was never checked:'Software\JavaSoft\Java Runtime Environment'\CurrentVersion'
(oddly placed'
chars not added by me).
No; What you want isn’t possible. Any compatibly shive wouldn’t apply to a Java application like you describe – Ramhound – 2019-08-17T00:27:20.920
@Ramhound Could you clarify? Do you mean to say that it is possible to override a registry key in the manner I've outlined, but the solution specifically does not work for any application that interacts with Java? The troublesome application itself is not built in Java, it just calls upon the JDK. There's a chance that the registry check is done C++-side. – TiberiumFusion – 2019-08-17T06:21:18.463
You indicated this was a Java program not a C++ program...No; I only meant that compatibly shives are not meant to override registry keys. – Ramhound – 2019-08-18T02:33:49.093
@Ramhound Yes, I do apologize for my poor choice of wording (it's edited now). When you say "not meant to override registry keys", do you that mean it can be done (but is a bad idea) or that it's simply impossible? – TiberiumFusion – 2019-08-18T06:06:06.027
I don't have any value named
CurrentVersion
anywhere underJavaSoft\Java Runtime Environment
. MyHKEY_CURRENT_USER\Software\JavaSoft\Java Runtime Environment\Security Baseline
contains multiple items, including1.8.0
and1.7.0
. Are you sure you have correctly analyzed the problem? – harrymc – 2019-08-18T17:33:36.197@harrymc The key in question is under local machine, not current user. So, it is
HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\CurrentVersion
– TiberiumFusion – 2019-08-18T21:52:28.093I don't have there either a value named
– harrymc – 2019-08-19T06:32:09.893CurrentVersion
. Java runtime is built to accommodate more than one version on the computer. Where did you get the idea ofCurrentVersion
being a problem? You may use Process Monitor to trace the program on registry access.@harrymc The troublesome application specifically lists the registry path (minus the hive). I went through some of my old notes on dealing with version-picky Java apps and can confirm that the CurrentVersion key has existed only under local machine (and never in current user) across all of my PCs. My use of the word "key" may be causing some confusion, though, since regedit unusually terms keys with no children as "values" and their value as "data". Since I'm not sure what's correct, here is the piece of data in question.
– TiberiumFusion – 2019-08-19T19:08:54.910Your Java version is different than mine, which is the source of the difference. I wonder where you are getting yours from. Mine is from Oracle, not JavaSoft. – harrymc – 2019-08-19T19:30:59.233
@harrymc I've updated my question with details from Process Monitor. I've been getting my JDKs and JREs from Oracle's download center for the past 7-8 years. But, I'm not a Java developer and I know virtually nothing about how the platform configures itself. – TiberiumFusion – 2019-08-19T19:47:04.303