简体   繁体   English

从Windows注册表中提取值

[英]Extracting values from Windows registry

Trying to write a windows cmd script to replicate the functionality of a linux shell script. 尝试编写Windows cmd脚本以复制linux shell脚本的功能。 In linux it is almost trivial because all of the source data needed is in text files, but in Windows I need to get it from the registry. 在linux中,这几乎是微不足道的,因为所需的所有源数据都在文本文件中,但是在Windows中,我需要从注册表中获取它。

Given an input string of, say 'xxxx', I am looking for key hklm\\SYSTEM\\CurrentControlSet\\Services\\OracleServiceXXXX. 给定输入字符串“ xxxx”,我正在寻找键hklm \\ SYSTEM \\ CurrentControlSet \\ Services \\ OracleServiceXXXX。 Under that key is a string named 'ImagePath', with a value of '\\bin\\ORACLE.EXE XXXX' 在该键下是一个名为'ImagePath'的字符串,其值为'\\ bin \\ ORACLE.EXE XXXX'

I need to get that 'somestring' into a script variable for further use. 我需要将该“ somestring”放入脚本变量中以备将来使用。

Solution needs to be in a .cmd script - no dependency on extra component installations like java, perl, etc. I'd guess PoweShell would be acceptable. 解决方案需要使用.cmd脚本-不依赖于java,perl等额外的组件安装。我猜PoweShell是可以接受的。 I just need to be sure I could drop the script onto any Windows server machine and know that the dependencies are there. 我只需要确保可以将脚本放到任何Windows服务器计算机上,并知道依赖项就在那里。

Something like: 就像是:

@set /p INPUT="Which string?"
reg query "HKLM\CurrentControlSet\Services\OracleService%INPUT%" /v ImagePath

?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM