Reputation: 9836
My question is how would I make a batch script instead of closing when the X in the top right is pressed to execute a file called exit.exe.
Upvotes: 2
Views: 2243
Reputation: 67256
There are a couple points in this question that are not clear enough:
starter.bat:
@echo off
echo Start yourScript.bat:
start "" /W yourScript.bat
echo Value returned from the script: %errorlevel%
if %errorlevel% neq 12345 ECHO execute exit.exe
yourScript.bat:
@echo off
echo I am the script.bat
set /P var=input value:
rem Terminate normally:
exit 12345
Upvotes: 5
Reputation: 56238
the [X] is "out of reach" for cmd
. Only way, I can think of is: create another cmd
to watch the presence of the current window:
@echo off
title WatchMe
more +7 %~f0 >t2.bat
start "watcher" t2.bat
exit /b
@echo off
:running
tasklist /v|find "WatchMe" >nul &&echo waiting || goto finished
timeout 1 >nul
goto running
:finished
echo "the process has finished
Upvotes: 3