@echo off

set curr_file=%cd%

set parentDir=%1
if %parentDir%=="" set deployDir=d:\webroot


set deployDir=%parentDir%\@project.artifactId@

set backupDir=%parentDir%\backup

set dateStr=%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%


cd /d %deployDir%

call stop.bat
sc query @project.artifactId@ |Find  "RUNNING" && ping 127.0.0.1 -n 10 >nul

cd /d %parentDir%

xcopy /Y/E/I project.artifactId@\lib %backupDir%\%dateStr%\@project.artifactId@lib
xcopy /Y/E/I project.artifactId@\config %backupDir%\%dateStr%\@project.artifactId@config
xcopy /Y/E/I project.artifactId@\*.jar %backupDir%\%dateStr%\@project.artifactId@
xcopy /Y/E/I project.artifactId@\*.bat %backupDir%\%dateStr%\@project.artifactId@
xcopy /Y/E/I project.artifactId@\*.exe %backupDir%\%dateStr%\@project.artifactId@
xcopy /Y/E/I project.artifactId@\*.xml %backupDir%\%dateStr%\@project.artifactId@


cd %curr_file%

rd/s/q %deployDir%\lib
rd/s/q %deployDir%\config
del /s/q %deployDir%\*.jar


xcopy /Y/E/I lib %deployDir%\lib
xcopy /Y/E/I config %deployDir%\config
xcopy /Y/E/I *.jar %deployDir%
xcopy /Y/E/I *.bat %deployDir%
xcopy /Y/E/I *.exe %deployDir%
xcopy /Y/E/I *.xml %deployDir%

cd /d %deployDir%
call auto.bat
cd %curr_file%