Batch files can not supress “terminate job”

后端 未结 2 754
后悔当初
后悔当初 2021-01-01 07:22

Im trying to open a 2nd batch file and detect if it normally exited or closed by a user (ctrl+c or x or window termiate etc..) so Im using this following example by Batch ru

2条回答
  •  生来不讨喜
    2021-01-01 07:35

    This works for me:

    call :runme start /w "Child Process" %comspec% /c "child.bat & exit 12345" NUL 2>NUL 
    echo %ERRORLEVEL%
    goto :eof
    
    :runme
    %*
    goto :eof
    

    The idea is to call a subroutine in the current script rather than calling out to an external script. You can still redirect input and output for a subroutine call.

提交回复
热议问题