简体   繁体   中英

batch - how can I close a batch file that was started from another batch file

I have a problem understanding how I can automatically close a batch file that was started from another batch file.

My first batch file looks like this:

@echo off

:logs
start C:\Users\Kenturrac\Desktop\copy.bat

timeout 2

goto logs

So as you can see there, I start another batch file called "copy.bat" which looks like that:

::set arma path
@set ARMAPATH=C:\Users\Administrator.WIN-B8I65OIU3DJ\Desktop\server\dayz_epoch_1

::set log path
@set LOGPATH=%ARMAPATH%\_LOGS
@set MOVEORCOPY=copy


:: Berechne Zeitstempel
@set DAY=%DATE:~0,2%
@set MONTH=%DATE:~3,2%
@set YEAR=%DATE:~6,4%
@set DATE=%YEAR%_%MONTH%_%DAY%

@set HH=%TIME:~0,2%
@IF "%TIME:~0,1%"==" " (
    set HH=0%TIME:~1,1%
)
@set MIN=%TIME:~3,2%
@set SEC=%TIME:~6,2%
@set TIME=%HH%%MIN%

@IF NOT EXIST "%LOGPATH%\%DATE%_%TIME%\" (
    @set TEMPPATH=%DATE%_-_%TIME%
) ELSE ( 
    @set TEMPPATH=%DATE%_-_%TIME%_%SEC%
)

@set TARGETPATH=%LOGPATH%\%TEMPPATH%\
@echo %TARGETPATH%

Exit /b

The problem is that it doesn't close the additional cmd window it started for the "copy.bat". If I use "call" instead of "start", it will mess up the "temppath" variable.

假设第二个批处理文件除了将环境变量设置为将在新进程中启动该批处理文件时将被丢弃的值之外,还要做其他事情,并且如果唯一不使用call而不是start是保护变量的值在第一个过程中,在第二个批处理中使用setlocal / endlocal指令,以避免文件关闭和变量值受干扰的问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM