标题: [注册表类] 关于bat批量查询注册表项是否存在的问题 [打印本页]
作者: dengwenbin 时间: 2020-6-5 13:47 标题: 关于bat批量查询注册表项是否存在的问题
我发现用下面命令可以实现查询注册表项是否存在,但是当需要查询的项多了之后,就会报错Windows 找不到文件C:\Users\bin\Desktop\logkey.txt.请确定文件名是否正确后,再试
求大神解答
@echo off
Set mykey="HKEY_LOCAL_MACHINE\SOFTWARE\123\1"^
^ "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Wow6432Node\MediaFoundation\Transforms\Categories\d6c02d4b-6833-45b4-971a-05a4b04bab91\0e799a91-cddc-471b-a803-2db82fafb726"^
^ "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Wow6432Node\MediaFoundation\Transforms\Categories\d6c02d4b-6833-45b4-971a-05a4b04bab91\17796aeb-0f66-4663-b8fb-99cbee0224ce"^
^ "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Wow6432Node\MediaFoundation\Transforms\Categories\d6c02d4b-6833-45b4-971a-05a4b04bab91\8c00c8ce-a6ba-442f-9185-2d68e4fca8eb"
Set LogFile=C:\Users\bin\Desktop\logkey.txt
If Exist %LogFile% Del %LogFile%
For %%K in (%mykey%) Do Call :Check_Key %%K %LogFile%
Start "" %LogFile%
Exit /b
:Check_Key
reg QUERY %1 >nul 2>&1
(
if %errorlevel% equ 0 ( echo %1 ===^> Found && reg QUERY %1
) else ( echo %1 ===^> Not found
)
) >>%2 2>&1
作者: flashercs 时间: 2020-6-5 14:38
本帖最后由 flashercs 于 2020-6-5 15:15 编辑
- @echo off
- %1 %2
- Set LogFile="C:\Users\bin\Desktop\logkey.txt"
- If Exist %LogFile% Del %LogFile%
-
- echo ::Check_Key
- For /f "delims=" %%K in ('"%~f0" goto mykey') Do Call :Check_Key %%K %LogFile%
-
- echo ::start %LogFile%
- Start "" %LogFile%
- Exit /b
-
- :mykey
- echo "HKEY_LOCAL_MACHINE\SOFTWARE\123\1"
- echo "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Wow6432Node\MediaFoundation\Transforms\Categories\d6c02d4b-6833-45b4-971a-05a4b04bab91\0e799a91-cddc-471b-a803-2db82fafb726"
- echo "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Wow6432Node\MediaFoundation\Transforms\Categories\d6c02d4b-6833-45b4-971a-05a4b04bab91\17796aeb-0f66-4663-b8fb-99cbee0224ce"
- echo "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Wow6432Node\MediaFoundation\Transforms\Categories\d6c02d4b-6833-45b4-971a-05a4b04bab91\8c00c8ce-a6ba-442f-9185-2d68e4fca8eb"
- exit /b
-
- :Check_Key
- reg QUERY %1 >nul 2>&1
- (
- if %errorlevel% equ 0 ( echo %1 ===^> Found && reg QUERY %1
- ) else ( echo %1 ===^> Not found
- )
- ) >>%2 2>&1
复制代码
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |