在查询批处理脚本注册表项 [英] Querying a registry key in a batch script
问题描述
我用下面的code得到的程序列表在启动时,并把它们记录到文件中运行。
I'm using the following code to get a list of programs being run at start up, and log them to a file.
FOR / F跳过= 2令牌= 1,2 *%% A有('REG QUERYHKCU \\ SOFTWARE \\ Wow6432Node \\微软\\的Windows \\ CurrentVersion \\ Run中2 ^> NUL ')做回声%%答:%% C >> Log.txt文件
这适用于其中值名称不包含空格条目,但是当它,比如用谷歌更新,它搅乱了记号,并%% C成为: REG_SZ <路径方式>
,而不是人的路
This works with entries where the value name doesn't contain a space, but when it does, such as with "Google Update", it messes up the tokens, and %%C becomes: REG_SZ <path>
, instead of just the path.
有没有人有更好的方式来查询注册表,并记录其价值?
Does anyone have a better way to query the registry and log its values?
推荐答案
好吧,我得到了一个工作的解决方案,我仍然希望,看看是否有人有更好的东西。
Well I got one working solution, I'd still love to see if anyone has anything better.
for /f "skip=2 tokens=*" %%A in ('REG QUERY "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" 2^>NUL') do (
set regstr=%%A
set regstr=!regstr: =^|!
for /f "tokens=1,3 delims= |" %%X in ("!regstr!") do (
echo %%X : %%Y
)
)
这篇关于在查询批处理脚本注册表项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!