@echo off
echo Updating your SIR-4000 Please Don't remove Power Source

cd \USB HD\Files\SIR4Kkiller\
ARMSDKSkeleton.exe

REM Setup SD Card With new format
copy "\USB HD\Files\autorun\*.*" "\SD CARD\AutoRun\"
copy "\USB HD\Files\RunSIR\*.*" "\SD CARD\AutoRun\RunSIR\"
copy "\USB HD\GSSI\AntDetect.exe" "\SD CARD\AutoRun\RunSIR\"
copy "\USB HD\Files\RunSIR4000.bat" "\SD CARD\AutoRun\RunSIR\"

REM Check if latest is installed
cd \FlashDisk\GSSI\SETUPS\
IF EXIST Version2225.txt GOTO UPDATESIR4K
IF EXIST Version2224.txt GOTO UPDATESIR4K
IF EXIST Version2217.txt GOTO UPDATESIR4K
IF EXIST Version2136.txt GOTO UPDATESIR4K
IF EXIST Version2017.TXT GOTO UPDATESIR4K

REM Check Status of process
cd \sd card\
IF EXIST OSComplete.txt GOTO ReloadSoftware
IF EXIST SoftwareComplete.txt GOTO RestoreSettings


:OSUpdate

REM Backup reg
cd \USB HD\Files\
4K_Registry_Preserver.exe

REM Rename AutoRun so Application doesn't start
cd \SD Card\
ren AutoRun xAutoRun

cd \SD Card\
echo OS Update Complete > OSComplete.txt

cd..

REM Copy new Update tools and Update Files
cd \usb hd\OS\
Copy *.exe \
copy *.nb0 \
copy *.dll \
copy *.cfg \
copy *.bmz \

cd..
UpdateTool.exe /u \SIR4K_CE8.cfg
UpdateTool.exe /cu

REM Restart SIR-4000
UpdateTool.exe /rc1000


:ReloadSoftware

REM Restore Registry
cd \USB HD\Files\
4K_Registry_Replacer.exe

cd \sd card\
del OSComplete.txt

REM Copy Sound Files
copy "\USB HD\Files\Sounds\*.wav" "\Flashdisk\Windows\"

echo Copying Setups

REM Copy DF SETUPS
copy "\USB HD\GSSI\SETUPS\DF\*.*" "\FlashDisk\GSSI\SETUPS\DF\"
copy "\USB HD\GSSI\SETUPS\DFE\*.*" "\FlashDisk\GSSI\SETUPS\DFE\"
copy "\USB HD\GSSI\SETUPS\DF3\*.*" "\FlashDisk\GSSI\SETUPS\DF3\"
copy "\USB HD\GSSI\SETUPS\DF3E\*.*" "\FlashDisk\GSSI\SETUPS\DF3E\"

REM Copy HS SETUPS
copy "\USB HD\GSSI\SETUPS\D2\*.*" "\FlashDisk\GSSI\SETUPS\D2\"
copy "\USB HD\GSSI\SETUPS\D2E\*.*" "\FlashDisk\GSSI\SETUPS\D2E\"
copy "\USB HD\GSSI\SETUPS\D3\*.*" "\FlashDisk\GSSI\SETUPS\D3\"
copy "\USB HD\GSSI\SETUPS\D3E\*.*" "\FlashDisk\GSSI\SETUPS\D3E\"

REM Copy Low Freq HS SETUPS
copy "\USB HD\GSSI\SETUPS\LF\*.*" "\FlashDisk\GSSI\SETUPS\LF\"
copy "\USB HD\GSSI\SETUPS\LFE\*.*" "\FlashDisk\GSSI\SETUPS\LFE\"
copy "\USB HD\GSSI\SETUPS\LF3\*.*" "\FlashDisk\GSSI\SETUPS\LF3\"
copy "\USB HD\GSSI\SETUPS\LF3E\*.*" "\FlashDisk\GSSI\SETUPS\LF3E\"

REM Copy New English Setups
copy "\USB HD\GSSI\SETUPS\QDE\*.*" "\FlashDisk\GSSI\SETUPS\QDE\"
copy "\USB HD\GSSI\SETUPS\XPE\*.*" "\FlashDisk\GSSI\SETUPS\XPE\"

REM Copy New Metric Setups
copy "\USB HD\GSSI\SETUPS\QD\*.*" "\FlashDisk\GSSI\SETUPS\QD\"
copy "\USB HD\GSSI\SETUPS\XP\*.*" "\FlashDisk\GSSI\SETUPS\XP\"

REM Tag that Update was done for future Updates
cd \FlashDisk\GSSI\SETUPS\
echo Complete Copying CE8 SETUPS > Version2224.TXT

cd \sd card\
echo GSSI Software Complete > SoftwareComplete.txt


:RestoreSettings

cd \sd card\
ren xAutoRun AutoRun
del SoftwareComplete.txt


:UPDATESIR4K

copy "\USB HD\GSSI\SIR4K\*.txt" "\Flashdisk\GSSI\"

REM Tag that Update was done for future Updates
cd \FlashDisk\GSSI\SETUPS\
echo Complete Update > Version2224.TXT

cd \USB HD\GSSI\SIR4KUpdater\
SIR4KUpdater.exe 1.1.8/auto

cd \USB HD\
del *.txt

cd \USB HD\
ren autoRun xautoRun

exit
