如何使用一个注册表项的值到另一个 [英] How to use value of one registry entry into another

查看:147
本文介绍了如何使用一个注册表项的值到另一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的一个Windows服务使用java.exe来运行。 java在我的C盘中的路径存储在注册表项中。 Java在更新发生时不断更新其修订版,并且不断删除旧文件夹并创建新文件夹。这条新路径需要在我的注册表项中更新,否则我的Windows服务会停止。

我能想到的一个解决方案是使用指向java路径的注册表项作为我的注册表项中的值,这样我的reg条目就没有硬编码的java路径。



基本上我想使用此注册表项中的值(即C:\Program Files(x86)\ Java \ _jre1.8.0_131 \ bin \\ \\ javaava。 exe)



HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\windows\CurrentVersion\App Paths\javaws.exe



在其他注册表项中:HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ EngineWithJenkins \Parameters @ Path



我是什么尝试过:



我使用过这两种方法却失败了:



$ (注册表:HKEY_LOCAL_MACHINE \ SOFTWARE \ Mysoftoft \windows \ CurrentVersion\App Paths\javaws.exe@Path)



并直接路径



HKEY_LOCAL_MA CHINE\SOFTWARE\Microsoft\windows\CurrentVersion\App Paths\javaws.exe\Path

One of my windows service uses the java.exe to run. The path where java lies in my C drive is stored in a registry entry. Java keeps updating its revision when updates happens and it keeps deleting the old folder and creates a new one. This new path needs to be updated in my registry entry other wise my windows service stops.
One solution I can think is use the registry entry that points to java path as a value in my registry entry, so that my reg entry does not have a hard coded java path.

Basically I want to use the value at this registry entry(which is C:\Program Files (x86)\Java\jre1.8.0_131\bin\javaws.exe)

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\windows\CurrentVersion\App Paths\javaws.exe

in other registry entry : HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EngineWithJenkins\Parameters@Path

What I have tried:

I have used these two methods but they failed:

$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\windows\CurrentVersion\App Paths\javaws.exe@Path)

and directly the path

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\windows\CurrentVersion\App Paths\javaws.exe\Path

推荐答案

(注册表:HKEY_LOCAL_MACHINE \ SOFTWARE \\ \\ Microsoft /\\windows \ CurrentVersion\App Paths \ javaHavaws.exe@Path)



直接路径



HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\windows\CurrentVersion\App Paths\javaws.exe\Path
(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\windows\CurrentVersion\App Paths\javaws.exe@Path)

and directly the path

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\windows\CurrentVersion\App Paths\javaws.exe\Path


您必须使用的注册表项Java安装,而不是这些值。提示:您还可以使用 EnumRegistry



另一种解决方案是使用 用FindFirstFile。请参阅示例代码。
You must use the registry entries of the Java installaion, not these values. Tip: You can also use EnumRegistry

Another solution is to find the javaws.exe in the program files folder of the disk with FindFirstFile. See the example code.


这篇关于如何使用一个注册表项的值到另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆