I used to add "EXIT" command at the end of my CMD scripts.
1. Is it good or bad ?
Here is bellow a CMD/BAT script launcher (Launcher.cmd).
It works fine but, if the selected launched script contains the EXIT command, the launcher process is killed (too) by this command. So, I cannot launch another script ;((
2. Is this the only way to solve my problem: "Just remove the EXIT command in all scripts" ?
3.1. Can WScript language do all or almost DOS language can do?
3.2. Do you know a WScript language tutorial/reference web site?
Thanks and regards
Launcher.cmd
Code: Select all
::--------------------------------------------------------- Pour Lancer Les BAT, CMD
@ECHO OFF
@SETLOCAL ENABLEDELAYEDEXPANSION
SET CurrFN=%~nx0
SET FileVN=FileN
:CHOI
ECHO.
ECHO.----------------
ECHO.Lancez un .CMD ^^!
ECHO.
SET /a Ci=0
FOR /f "Delims=" %%f in ('DIR /b /on /a-d "*.CMd" "*.BAT"') DO (
SET File=%%~nxf
IF /i NOT "!File!"=="!CurrFN!" (
SET /a Ci+=1
IF !Ci! LSS 10 (ECHO. !Ci! !File!) ELSE (ECHO. !Ci! !File!)
SET !FileVN!!Ci!=!File!
)
)
ECHO.
SET Choix=
SET /P Choix=Choix: (1-%Ci%) ?
IF /i "%Choix%"=="" GOTO:FinN
IF NOT "%Choix%"=="" SET Choix=%Choix:~0,2%
SET FilCMD=!%FileVN%%Choix%!
IF EXIST "%FilCMD%" (Call "%FilCMD%") ELSE (ECHO.&ECHO.*** Choice ERROR)
GOTO:CHOI
:FinN
ENDLOCAL&ECHO.END. BYE ..... &PING -n 3 LocalHost>Nul&EXIT ::___________________
Test.bat (put this file next Launcher.cmd, and run Launcher.cmd)
Code: Select all
@ECHO OFF
ECHO.I am [%~nx0] running ...
ECHO.How to properly exit [%~nx0] without killing the script that called me ??
::Pause&EXIT