I am performing one task where I have to run one .jar file using batch file which is called by another batch file. After execution I need to delete some junk files. Code to delete files is written in the same calling batch file.
Now issue is that once .jar file starts executing , command window closes and then control never comes back to batch file execution hence my delete code never works.
Is there any way to resolve this issue.
Thanks Amit
Below is the code I am using.
@Echo off
echo "your file is getting processed...."
md %userprofile%\temp
echo %userprofile%\temp
'"C:\Program Files\winzip\Winzip64.exe" -min -e -o C:\mysoft\Benchmarks\Windows7.zip %userprofile%\temp
C:
cd %userprofile%\temp\Windows7
echo going to execute file...
soft-CAT.bat -a -s -n -csv -b benchmarks\soft_Microsoft_Windows_7_Benchmark_v2.1.0-xccdf.xml -p "Level 1 + BitLocker" -r c:\
set folder="C:\test\junk"
cd /d %folder%
for /F "delims=" %%i in ('dir /b') do (rmdir "%%i" /s/q || del "%%i" /s/q)
ECHO "Successfully Evaluated"
Exit
Called batch file
@ECHO OFF
::
:: Wrapper for invoking soft-CAT
::
SET DEBUG=0
SET JAVA=java
::
:: Detect if Java is in the path
::
%JAVA% 2> NUL > NUL
IF NOT %ERRORLEVEL%==9009 IF NOT %ERRORLEVEL%==3 GOTO RUNSOFTCAT
::
:: If Java is not in the PATH, try finding it at JAVA_HOME\bin
::
SET JAVA=%JAVA_HOME%\bin\java.exe
%JAVA% 2> NUL > NUL
IF NOT %ERRORLEVEL%==9009 IF NOT %ERRORLEVEL%==3 GOTO RUNSOFTCAT
::
:: See if x86 JRE5 is in the default location
::
SET JAVA=C:\PROGRA~2\Java\jre5\bin\java.exe
%JAVA% 2> NUL > NUL
IF NOT %ERRORLEVEL%==9009 IF NOT %ERRORLEVEL%==3 GOTO RUNSOFTCAT
::
:: See if x86 JRE6 is in the default location
::
SET JAVA=C:\PROGRA~2\Java\jre6\bin\java.exe
%JAVA% 2> NUL > NUL
IF NOT %ERRORLEVEL%==9009 IF NOT %ERRORLEVEL%==3 GOTO RUNSOFTCAT
::
:: See if x86 JRE7 is in the default location
::
SET JAVA=C:\PROGRA~2\Java\jre7\bin\java.exe
%JAVA% 2> NUL > NUL
IF NOT %ERRORLEVEL%==9009 IF NOT %ERRORLEVEL%==3 GOTO RUNSOFTCAT
::
:: See if x86 JRE8 is in the default location
::
SET JAVA=C:\PROGRA~2\Java\jre8\bin\java.exe
%JAVA% 2> NUL > NUL
IF NOT %ERRORLEVEL%==9009 IF NOT %ERRORLEVEL%==3 GOTO RUNSOFTCAT
::
:: See if JRE6 is in the default location
::
SET JAVA=C:\PROGRA~1\Java\jre6\bin\java.exe
%JAVA% 2> NUL > NUL
IF NOT %ERRORLEVEL%==9009 IF NOT %ERRORLEVEL%==3 GOTO RUNSOFTCAT
::
:: See if JRE7 is in the default location
::
SET JAVA=C:\PROGRA~1\Java\jre7\bin\java.exe
%JAVA% 2> NUL > NUL
IF NOT %ERRORLEVEL%==9009 IF NOT %ERRORLEVEL%==3 GOTO RUNSOFTCAT
::
:: See if JRE8 is in the default location
::
SET JAVA=C:\PROGRA~1\Java\jre8\bin\java.exe
%JAVA% 2> NUL > NUL
IF NOT %ERRORLEVEL%==9009 IF NOT %ERRORLEVEL%==3 GOTO RUNSOFTCAT
IF %ERRORLEVEL%==9009 GOTO NOJAVAERROR
IF %ERRORLEVEL%==3 GOTO NOJAVAERROR
::
:: Invoke SOFT-CAT with a 768MB heap
::
:RUNSOFTCAT
IF %DEBUG%==1 (
ECHO Found Java at %JAVA%
%JAVA% -Xmx768M -jar SOFTCAT.jar %* --verbose
) ELSE (
%JAVA% -Xmx768M -jar SOFTCAT.jar %*
)
echo "I am in main file, execution is done...."
GOTO EXIT
:NOJAVAERROR
ECHO The Java runtime was not found in PATH, default install locations, or JAVA_HOME. Please ensure Java is installed.
PAUSE
:EXIT