获取注册表项中的价值 [英] Get Value of Registry Key
本文介绍了获取注册表项中的价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个批处理脚本来检查,如果一个注册表项存在,如果它存在,然后打开Internet Explorer。我现在想要做的是得到系统登录键的值,并把它的URL。我怎样才能做到这一点?
I have a batch script that checks if a registry key exists and if it does exist then open Internet explorer. What I now want to do is get the value of that registery key and put it in the URL. How can I do this?
@echo off
reg query HKLM\Software\Test\Monitor\Settings
if errorlevel 1 goto not_exist
goto exist
:not_exist
:exist
start "Test" "%ProgramFiles%\Internet Explorer\iexplore.exe" http://localhost:/dashboard.php
感谢所有的任何帮助。
Thanks all for any help.
推荐答案
在这里你去,应该是自我解释与评论。让我知道如果你有任何问题。
Here you go, should be self explanatory with comments. Let me know if you have any questions.
@echo off
set THEME_REGKEY=HKLM\Software\Microsoft\Windows\CurrentVersion\Themes
set THEME_REGVAL=ThemeName
REM Check for presence of key first.
reg query %THEME_REGKEY% /v %THEME_REGVAL% 2>nul || (echo No theme name present! & exit /b 1)
REM query the value. pipe it through findstr in order to find the matching line that has the value. only grab token 3 and the remainder of the line. %%b is what we are interested in here.
set THEME_NAME=
for /f "tokens=2,*" %%a in ('reg query %THEME_REGKEY% /v %THEME_REGVAL% ^| findstr %THEME_REGVAL%') do (
set THEME_NAME=%%b
)
REM Possibly no value set
if not defined THEME_NAME (echo No theme name present! & exit /b 1)
REM replace any spaces with +
set THEME_NAME=%THEME_NAME: =+%
REM open up the default browser, searching google for the theme name
start http://www.google.com/search?q=%THEME_NAME%
这篇关于获取注册表项中的价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文