开发者

Run multiple bat files within bat and passing arguments

My problem is related to pass开发者_如何学运维ing arguments to bat files. The first argument is passed correctly to the bat but the second time the argument is passed it's emtpy.

Example:

set comport = com4
call bat1.bat %comport%       ->comport is com4
if errorlevel 1 goto end
call bat2.bat %comport%       ->comport is empty

so after the first call of bat1.bat comport is empty. How can I make the call argument on the "main" bat level stay in memory after the call of the bat1.bat?


@echo off
set comport=com4
setlocal&(call bat1.bat %comport%)&endlocal
if errorlevel 1 goto end
call bat2.bat %comport%
:end

setlocal only works on WinNT4+, not DOS or Win9x, if you need to support those you would have to save %comport% to some other variable before calling bat1.bat and then restore the value

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜