小编use*_*173的帖子

如何将值从一个批处理文件返回到调用者批处理文件

我有一个常见的.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!" ( …
Run Code Online (Sandbox Code Playgroud)

batch-file command-line-arguments

14
推荐指数
1
解决办法
4万
查看次数

标签 统计

batch-file ×1

command-line-arguments ×1