My bat file on Windows 7 stops executing at echo lines. I have to hit ENTER to continue. For example it will pause at line:
echo Stopping service.
An almost identical script file runs fine from beginning to end as desired.
Encoding is ANSI. Running on Windows 7 64-bits.
What am I missing?
Complete example:
@echo off
set _JAVA_OPTIONS="-Djava.net.preferIPv4Stack=true"
rem Make sure user is running this as an admin
rem ref http://stackoverflow.com/questions/4051883/batch-script-how-to-check-for-admin-rights
net session >nul 2>&1
if %errorLevel% == 0 (
rem echo Administrative permissions confirmed.
rem %~dp0 will give you the full path to the batch file's directory (fixed
IF EXIST "%~dp0"\Service\yajsw-beta-12.01\yajsw-beta-12.01\bat\stopService.bat (
rem echo Found required file %~dp0Service\yajsw-beta-12.01\yajsw-beta-12.01\bat\stopService.bat
) ELSE (
echo Required file %~dp0Service\yajsw-beta-12.01\yajsw-beta-12.01\bat\stopService.bat was not found!
GOTO:EOF
)
IF EXIST "%~dp0"\Service\yajsw-beta-12.01\yajsw-beta-12.01\bat\uninstallService.bat (
rem echo Found required file %~dp0Service\yajsw-beta-12.01\yajsw-beta-12.01\bat\uninstallService.bat
) ELSE (
echo Required file %~dp0Service\yajsw-beta-12.01\yajsw-beta-12.01\bat\uninstallService.bat was not found!
GOTO:EOF
)
IF EXIST "%~dp0"\Service\yajsw-beta-12.01\yajsw-beta-12.01\conf\wrapper.conf (
rem echo Found required file %~dp0Service\yajsw-beta-12.01\yajsw-beta-12.01\conf\wrapper.conf
) ELSE (
echo Required file %~dp0Service\yajsw-beta-12.01\yajsw-beta-12.01\conf\wrapper.conf was not found!
GOTO:EOF
)
echo Stopping service.
"%~dp0"\Service\yajsw-beta-12.01\yajsw-beta-12.01\bat\stopService.bat >nul 2>&1
@echo Uninstalling service. One moment...
rem Sleep ref http://stackoverflow.com/questions/4527877/batch-script-read-line-by-line
ping -n 4 127.0.0.1 >nul
"%~dp0"\Service\yajsw-beta-12.01\yajsw-beta-12.01\bat\uninstallService.bat >nul 2>&1
cd %~dp0
echo Completed.
echo The LCSC service has been removed from
echo Control Panel ^> Administrative Tools ^> Windows Services
) else (
echo No can do!
echo Please execute this file as a Windows administrator
echo by clicking
echo Start button ^> All Programs ^> Accessories ^>
echo then right click on the command prompt icon and select
echo "Run as an Administrator"
pause
GOTO:EOF
)
TIA, Bertrand