cd c:\tmp
echo version is %1
echo deleting older src folders

rem delete older version source files using for loop
for /d %%G in ("C:\tmp\EnTrak_V*") do rd /s /q "%%~G"

echo unzipping current version files
unzip.exe Tmpfile.zip

del Tmpfile.zip unzip.exe
IF EXIST "C:\Program Files (x86)\Ampps\www\EnTrak\EnTrak\ProjectsList.csv" (
  copy /Y "C:\Program Files (x86)\Ampps\www\EnTrak\EnTrak\ProjectsList.csv" C:\tmp\PL.csv
)
IF EXIST "C:\Program Files\Ampps\www\EnTrak\EnTrak\ProjectsList.csv" (
  copy /Y "C:\Program Files\Ampps\www\EnTrak\EnTrak\ProjectsList.csv" C:\tmp\PL.csv
)

cd C:\tmp\EnTrak_V%1_src

call UnInstaller.bat auto

cd C:\tmp\EnTrak_V%1_src
call Installer.bat auto

cd c:\tmp
rd /s /q C:\tmp\EnTrak_V%1_src

IF EXIST "C:\Program Files (x86)\Ampps\www\EnTrak\EnTrak" (
  copy /Y C:\tmp\PL.csv "C:\Program Files (x86)\Ampps\www\EnTrak\EnTrak\ProjectsList.csv"
)
IF EXIST "C:\Program Files\Ampps\www\EnTrak\EnTrak" (
  copy /Y C:\tmp\PL.csv "C:\Program Files\Ampps\www\EnTrak\EnTrak\ProjectsList.csv"
)

echo New version installed exiting ...
timeout 2
exit
