![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-09-13 23:20 |
47,812 topics / 349,916 posts / today 0 new / 48,268 members |
| 论坛回收站 » [Help] Code Simplification |
| Printable Version 1,859 / 0 |
| Floor1 bluewing009 | Posted 2010-01-28 23:21 |
| 新手上路 Posts 18 Credits 18 | |
|
The code is as follows:
------------------------------------------------------ @echo off set "v123=不存在" & set "v456=不存在" & set "v789=不存在" & set "vabc=不存在" for /f "tokens=3" %%i in ('reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" ^| find /i "123"') do if "%%i"=="0x1" set "v123=存在" for /f "tokens=3" %%i in ('reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" ^| find /i "456"') do if "%%i"=="0x1" set "v456=存在" for /f "tokens=3" %%i in ('reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" ^| find /i "789"') do if "%%i"=="0x1" set "v789=存在" for /f "tokens=3" %%i in ('reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" ^| find /i "abc"') do if "%%i"=="0x1" set "vabc=存在" echo 123 key %v123% echo 456 key %v456% echo 789 key %v789% echo abc key %vabc% pause ------------------------------------------------------ To simplify it, especially in terms of the size and the number of for loops, you can do the following: ------------------------------------------------------ @echo off set "keys=123 456 789 abc" setlocal enabledelayedexpansion for %%k in (%keys%) do ( set "v%%k=不存在" for /f "tokens=3" %%i in ('reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" ^| find /i "%%k"') do ( if "%%i"=="0x1" set "v%%k=存在" ) echo %%k key !v%%k! ) endlocal pause ------------------------------------------------------ |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |