我想通过&在一个值作为参数。在下面的示例代码中,我可以成功回显FILE_NAME,但如何将其作为参数传递给:TEE标签?
@ECHO OFF
CLS
SETLOCAL ENABLEDELAYEDEXPANSION
SET FILE_PATH=C:\TEMP\FILE^&NAME.TXT
REM THIS WORKS
ECHO !FILE_PATH!
REM THIS DOES NOT WORK
CALL :TEE !FILE_PATH!
GOTO :EOF
:TEE
FOR /F "TOKENS=*" %%Z IN ("%*") DO (
ECHO %%Z
> CON ECHO.%%Z
>> "!LOG_FILE!" ECHO.%%Z
GOTO :EOF
)
GOTO :EOF
答案 0 :(得分:3)
@ECHO OFF
CLS
SETLOCAL ENABLEDELAYEDEXPANSION
SET FILE_PATH=C:\TEMP\FILE^&NAME.TXT
REM THIS WORKS
ECHO !FILE_PATH!
REM THIS DOES NOT WORK
CALL :TEE "%FILE_PATH%"
GOTO :EOF
:TEE
FOR /F "TOKENS=* USEBACKQ" %%Z IN ('%*') DO (
ECHO %%~Z
> CON ECHO.%%~Z
>> "!LOG_FILE!" ECHO.%%~Z
GOTO :EOF
)
GOTO :EOF
是的,它是 - 这是单程