|
|
楼主 |
发表于 2024-8-21 15:17:19
|
显示全部楼层
本帖最后由 delab-1 于 2024-8-21 15:29 编辑
回复 6# 77七
有没有办法处理呢?在程序中已经每个批处理都让其回到程序所在的目录之下(code)了,在子批处理叠加的文件中,并回到子目录了。我做了改动,强行将其拉回程序所在目录(code),后续运行能顺序运行。
call s1.bat
call s2.bat
::强行拉回到code目录
cd ..\code
call s3.bat
::强行拉回到code目录
cd ..\agg_aug16
call s4.bat
::强行拉回到code目录
cd ..\agg_aug16
call s5.bat
经过上述处理后,程序就可以顺利运行了。但是,有个地方正如您所说,在S1.bat中,程序如下,其中没有使用setlocal enabledelayedexpansion, 就没有出现问题,所以其后的S2.bat可以正常跟随运行。但是,也的确如您所说,凡是使用setlocal enabledelayedexpansion,回到根目录下code的popd就在子批处理后失效了,后面的s2.bat,S3.bat,S4.bat,S5.bat都用了setlocal enabledelayedexpansion,就必须强加cd ..\code 语句,强行将其拉回到程序所在目录。现在的问题是,是否在S2之后的所有程序中,加入endlocal disabledelayedexpansion会不会解决上述问题呢?
if exist ..\2017\*.txt del ..\2017\*.txt
::------------------------------------------
:: S1:writing all com to txt file
::------------------------------------------
goto next
tablo -wfp set_for_map
call LTG set_for_map
:next
for /L %%a in (2017,1,2017) do (
pushd ..\%%a
if exist *.txt del *.txt
copy ..\agg_aug16\set_for_map.exe
copy ..\agg_aug16\set_for_map.axs
copy ..\agg_aug16\set_for_map.axt
copy ..\agg_aug16\set_for_map.cmf
dir all*.har /b/od>temp_list.txt
for /f %%b in (temp_list.txt) do (
copy set_for_map.cmf temp.cmf
strrpc xxxx %%~nb /i /c /s:temp.cmf
set_for_map.exe -cmf temp.cmf
if errorlevel 1 pause
)
popd
) |
|