我正在编写Windows批处理脚本,并且以下行始终显示错误消息,但如果从命令行直接运行则它正常工作。
IF %p_monitorName%=="workflow_failed" (
for /F "tokens=1 delims=," %a in ("%p_monitorStatus: by =.%") do for /F "tokens=3 delims=:" %b in ("%a: by =.%") do for /F "tokens=1 delims= " %c in ("%b by =.%") do echo %c >> %scriptdir%\..\logs\SIS2OVOOutput.txt
)
这是错误消息:
9480 ERROR: , Unknown error (255) end perfex
答案 0 :(得分:0)
在bat文件中,你必须在for循环中使用%%
而不是%
:
IF %p_monitorName%=="workflow_failed" (
for /F "tokens=1 delims=," %%a in ("%p_monitorStatus: by =.%") do for /F "tokens=3 delims=:" %%b in ("%%a: by =.%") do for /F "tokens=1 delims= " %%c in ("%%b by =.%") do echo %%c >> %scriptdir%\..\logs\SIS2OVOOutput.txt
)
应该是它。