I have a batch script with multiple if conditions.
- Check if a folder
C:\Apps\WorkingFolder\NewApplnexists.- If it doesn't exist execute a
.jarfrom a network drive,G:. - If it does exist compare a file
CheckDate.logon both the local drive and network drive.- If logs are the same, execute a
.jarfrom a network drive,G:. - If logs are different, rename the existing
foldertofolder_sysdatein local, and execute a.jarfrom a network drive,G:.
- If logs are the same, execute a
- If it doesn't exist execute a
Here is my code
@ echo on
SETLOCAL EnableDelayedExpansion
IF EXIST C:\Apps\Workingfolder\NewAppln\ (goto FOUND) else ( goto NOTFOUND)
:EOF
: FOUND
FC C:\Apps\Workingfolder\NewAppln\CheckDate.log G:\Workingfolder\NewAppln\CheckDate.log | find "***">NUL
(IF ERRORLEVEL 1 (GOTO SAME) ELSE (GOTO DIFFERENT)
GOTO :EOF
:SAME
@"G:\JRE1.509\bin\java" -jar "loadApp.jar"
START /D"C:\Apps\Workingfolder\NewAppln" MyApp.exe
GOTO :EOF
:DIFFERENT
move C:\Apps\Workingfolder\NewAppln C:\Apps\Workingfolder\NewAppln_%time:~0,2%%time:~3,2%-%DATE:/=%
@"G:\JRE1.509\bin\java" -jar "loadApp.jar"
START /D"C:\Apps\Workingfolder\NewAppln" MyApp.exe
)
:EOF
:NOTFOUND
cd G:\Workingfolder\NewAppln_WIN10\
@"G:\JRE1.509\bin\java" -jar "loadApp.jar"
START /D"C:\Apps\Workingfolder\NewAppln" MyApp.exe