我的问题与向bat文件传递参数有关。第一个参数被正确地传递给bat,但是第二次参数被传递时,它是emtpy。
示例:
set comport = com4
call bat1.bat %comport% ->comport is com4
if errorlevel 1 goto end
call bat2.bat %comport% ->comport is empty所以在第一次调用bat1.bat之后,comport是空的。在调用bat1.bat之后,如何让"main“bat级别上的调用参数留在内存中?
发布于 2011-02-24 18:00:28
@echo off
set comport=com4
setlocal&(call bat1.bat %comport%)&endlocal
if errorlevel 1 goto end
call bat2.bat %comport%
:endsetlocal只能在WinNT4+上运行,不能在DOS或Win9x上运行,如果你需要支持它们,你必须在调用bat1.bat之前将%comport%保存到其他变量中,然后恢复该值
https://stackoverflow.com/questions/5094420
复制相似问题