可以兼容路径中含\0和空格的情况,不要想合并到一行- @echo off
- setlocal enabledelayedexpansion
- set Lf=^
-
-
- for /f %%i in ('copy /z "%~0" nul') do for %%j in ("!Lf!") do (
- endlocal
- for /f "tokens=1,2*" %%a in ('reg query "HKCU\123" /se ^^^|')do (
- if /i "%%a" == "test" (
- set "var=%%c"
- setlocal enabledelayedexpansion
- echo,!var:^|=%%i%%~j!
- )
- )
- )
复制代码
Microsoft Windows [版本 6.1.7601]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。
C:\Windows\System32>reg query "HKCU\123" /se ^|
HKEY_CURRENT_USER\123
test REG_MULTI_SZ (Start "" "C:\a b c\01.exe")|(Start C:\2.exe)|(Start
C:\3.exe)
C:\Windows\System32>C:\Users\apang\Desktop\test.bat
(Start "" "C:\a b c\01.exe")
(Start C:\2.exe)
(Start C:\3.exe)
C:\Windows\System32> |