Grepping `reg query` result value?

强颜欢笑 提交于 2020-01-06 04:27:11

问题


Consider the following result from a hypothetical reg query:

..>reg query HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\MediaPlayer /v "I
nstallation Directory"

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\MediaPlayer
    Installation Directory    REG_EXPAND_SZ    %ProgramFiles%\Windows Media Play
er

How do I grep the output so that I can assign the actual value of the setting (%ProgramFiles%\...) into a variable (or temp file)?


回答1:


example for batch files:

@FOR /F "tokens=2* " %%A IN ('reg query HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\MediaPlayer /v "Installation Directory"') DO @SET PARAM=%%B 

If you want to use it directly in console - use single percent sign to denote variables (i.e. %A and %B)



来源:https://stackoverflow.com/questions/4073486/grepping-reg-query-result-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!