1.

Solve : Exit message to quit .bat program?

Answer»

Hi all
Does anyone know how I can display a customisable message so that I can press a key when I need to QUIT the .bat executable instead of the program closing itself?
Something like "Please press any key to exit this program".

What I have is this at the MOMENT.. see where the PAUSE and stars are, I need to be able to put something there so user can press any key.. then exit out of program.

@echo off
:BEGIN
SET /p variable=[Enter the log FILE you need report(s) on] (e.g YYYYMMDD.txt) :
echo Please wait for file search..
find /n "538" c:\%variable% > c:\userlogoff.txt

IF EXIST "c:\%variable%" echo Userlogoff.txt file has now been generated..Program now exiting - Goodbye.
PAUSE *****************
IF NOT EXIST "c:\%variable%" echo You are required to re-enter a file name that exists:
IF NOT EXIST "c:\%variable%" goto Begin
:END

Thanks,
Laura
If you are running under XP, a neat solution would be
Code: [Select]@echo off
:BEGIN
echo You are required to enter a file name that exists

SET /p variable=[Enter the log file you need report(s) on] (e.g YYYYMMDD.txt) :

IF NOT EXIST "c:\%variable%" goto Begin

echo Please wait for file search..
find /n "538" c:\%variable% > c:\userlogoff.txt

SET /p dummy=Userlogoff.txt file has now been generated.. Press return to exit
echo Goodbye.
:END The only thing is, the user does need to press return

Your logic is slightly skewed, you should test the failure CONDITION FIRST before trying to search it



Discussion

No Comment Found