【发布时间】:2013-07-19 00:00:14
【问题描述】:
我有一个通用的 .bat 文件,它读取 status.xml 文件并找出状态字段的值。这个批处理文件然后被其他批处理文件调用以找出状态值。调用批处理文件将文件名发送到公共 bat 文件。 我无法将公共批处理文件中的状态发送到调用批处理文件。 有人可以帮忙吗?
main batch file
-- will call the common bat file and send the file name and a variable as arguments
setlocal
call Common.bat c:\folderdir\files\status.xml val1
-- trying to print the status returned by the common bat file
echo [%val1%]
common batch file
@ECHO off
setlocal EnableDelayedExpansion
rem will loop through the file and read the value of the status tag
(for /F "delims=" %%a in (%1) do (
set "line=%%a"
set "newLine=!line:<Interface_status>=!"
set "newLine=!newLine:</Interface_status>=!"
if "!newLine!" neq "!line!" (
@echo Status is !newLine!
rem I want to send`enter code here` the value of newLine to the calling batch file
set %~2 = !newLine! <--this does not work
)
))
【问题讨论】:
标签: batch-file command-line-arguments