@echo off
set ScriptDir=%~dp0
set ScriptDir=%ScriptDir:~0,-1%

reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\x64" >> nul 2>&1
echo %ERRORLEVEL%
if %ERRORLEVEL% NEQ 0 (
	"%~dp0\VC_redist.x64.exe" /install /quiet /norestart
)

set VALUE_CMD="%ScriptDir%\ValUECmd-2.38.2\ValUECmd.exe"
set VALUE_CMD_DEBUG_ARGS=

set OLD_FW_USBH="%ScriptDir%\None"
set OLD_FW_USBD="%ScriptDir%\OPUS-RX_USBD_OLD.hex"
set NEW_FW_USBH="%ScriptDir%\None"
set NEW_FW_USBD="%ScriptDir%\OPUS-RX_USBD_7.5.21.ihex"
set NEW_UPT="%ScriptDir%\OPUS-RX_new_7.5.21.upt"

%VALUE_CMD% RUN "%ScriptDir%\AtlonaUpgradeLocalVS2k.vcs" %VALUE_CMD_DEBUG_ARGS% --args %OLD_FW_USBH% %OLD_FW_USBD% - %NEW_FW_USBH% %NEW_FW_USBD% %NEW_UPT%
pause