Solved Windows batch file closing down

June 8, 2012 at 01:11:52
Specs: Windows XP
I have a windows batch file which execute few steps. The file look like as below:

set ZP_DIR=lifepro114\114\src\custom

set /p Run_View=What is the name of the view? 

set SD=%Run_View%

set /p Run_pgm=What is the name of the program? 

set PG=%Run_pgm%

U:

CD %SD%\%ZP_DIR%

CALL compfj %PG% %SD%
echo ERRORLEVEL = %ERRORLEVEL%
if errorlevel 1 goto :fail


:success
echo Compiled Successfully
goto :end

:fail
echo Compilation Failure
goto :end

:end
pause

My problem is it is closing down the command promt once the execution is completed. How to stop this.Please help.


See More: Windows batch file closing down

Report •

#1
June 8, 2012 at 03:51:11
✔ Best Answer
After pause, use:
exit /B

Why?

Fri 06/08
 5:49:38=>exit /?
Quits the CMD.EXE program (command interpreter) or the current batch
script.

EXIT [/B] [exitCode]

  /B          specifies to exit the current batch script instead of
              CMD.EXE.  If executed from outside a batch script, it
              will quit CMD.EXE

  exitCode    specifies a numeric number.  if /B is specified, sets
              ERRORLEVEL that number.  If quitting CMD.EXE, sets the process
              exit code with that number.

Fri 06/08
 5:50:06=>

When your only tool is a hammer, every problem looks like a nail.


Report •

#2
June 13, 2012 at 12:09:43
I thought that you have to use quotes after the set /p variable="", i suppose I am out of date though?

:: mike


Report •

#3
June 13, 2012 at 13:27:04
That code worked for fine for me.

Maybe explain your issue a little more.

Tony


Report •
Related Solutions


Ask Question