@echo off setlocal EnableExtensions EnableDelayedExpansion set "BASE_URL=https://www.controlevr.com.br" set "DEST=%USERPROFILE%\Documents\ControleVR\InclusaoInsumos" if not exist "%DEST%" mkdir "%DEST%" echo. echo Baixando arquivos da automacao... set "CACHE_BUSTER=%RANDOM%%RANDOM%" powershell -NoProfile -Command "try { Invoke-WebRequest -UseBasicParsing -Headers @{'Cache-Control'='no-cache'} -Uri '%BASE_URL%/static/automacao/IncluirInsumosPlataforma.ahk?v=%CACHE_BUSTER%' -OutFile '%DEST%\IncluirInsumosPlataforma.ahk.novo'; exit 0 } catch { exit 1 }" if errorlevel 1 goto :falha_download powershell -NoProfile -Command "try { Invoke-WebRequest -UseBasicParsing -Headers @{'Cache-Control'='no-cache'} -Uri '%BASE_URL%/static/automacao/launcher_insumos.ahk?v=%CACHE_BUSTER%' -OutFile '%DEST%\launcher_insumos.ahk.novo'; exit 0 } catch { exit 1 }" if errorlevel 1 goto :falha_download powershell -NoProfile -Command "try { Invoke-WebRequest -UseBasicParsing -Headers @{'Cache-Control'='no-cache'} -Uri '%BASE_URL%/static/automacao/abrir_insumos.cmd?v=%CACHE_BUSTER%' -OutFile '%DEST%\abrir_insumos.cmd.novo'; exit 0 } catch { exit 1 }" if errorlevel 1 goto :falha_download move /y "%DEST%\IncluirInsumosPlataforma.ahk.novo" "%DEST%\IncluirInsumosPlataforma.ahk" >nul if errorlevel 1 goto :falha_download move /y "%DEST%\launcher_insumos.ahk.novo" "%DEST%\launcher_insumos.ahk" >nul if errorlevel 1 goto :falha_download move /y "%DEST%\abrir_insumos.cmd.novo" "%DEST%\abrir_insumos.cmd" >nul if errorlevel 1 goto :falha_download if not exist "%DEST%\IncluirInsumosPlataforma.ahk" goto :falha_download if not exist "%DEST%\launcher_insumos.ahk" goto :falha_download if not exist "%DEST%\abrir_insumos.cmd" goto :falha_download :: Detecta o executavel do AutoHotkey em varias localizacoes possiveis set "AHK_EXE=" if exist "C:\Program Files\AutoHotkey\AutoHotkey.exe" set "AHK_EXE=C:\Program Files\AutoHotkey\AutoHotkey.exe" if exist "C:\Program Files\AutoHotkey\AutoHotkeyU64.exe" set "AHK_EXE=C:\Program Files\AutoHotkey\AutoHotkeyU64.exe" if exist "C:\Program Files\AutoHotkey\AutoHotkeyU32.exe" set "AHK_EXE=C:\Program Files\AutoHotkey\AutoHotkeyU32.exe" if exist "C:\Program Files (x86)\AutoHotkey\AutoHotkey.exe" set "AHK_EXE=C:\Program Files (x86)\AutoHotkey\AutoHotkey.exe" if "%AHK_EXE%"=="" ( echo. echo AutoHotkey v1.1 ^(Legacy^) nao encontrado neste computador. echo Esta automacao ainda nao e compativel com AutoHotkey v2. echo Instale a versao v1.1 em https://www.autohotkey.com/ e rode este instalador de novo. pause exit /b 1 ) echo AutoHotkey encontrado em: %AHK_EXE% echo. echo Registrando a automacao neste computador... reg add "HKCU\Software\Classes\vrinsumos" /ve /d "URL:VR Insumos Protocol" /f >nul if errorlevel 1 goto :falha_registro reg add "HKCU\Software\Classes\vrinsumos" /v "URL Protocol" /t REG_SZ /d "" /f >nul if errorlevel 1 goto :falha_registro reg add "HKCU\Software\Classes\vrinsumos\shell\open\command" /ve /d "\"%ComSpec%\" /d /s /c \"\"%DEST%\abrir_insumos.cmd\" \"%%1\"\"" /f >nul if errorlevel 1 goto :falha_registro echo. echo Instalacao concluida! echo Pode voltar na plataforma, clicar em "Preparar" e depois em "Abrir automacao". echo. pause exit /b 0 :falha_download del /q "%DEST%\IncluirInsumosPlataforma.ahk.novo" "%DEST%\launcher_insumos.ahk.novo" "%DEST%\abrir_insumos.cmd.novo" 2>nul echo. echo Falha ao baixar a atualizacao. Verifique sua conexao e tente novamente. pause exit /b 1 :falha_registro echo. echo Os arquivos foram baixados, mas nao foi possivel registrar o link "Abrir automacao" no Windows. echo Tente executar este instalador novamente. pause exit /b 1