@echo off setlocal EnableExtensions EnableDelayedExpansion set "BASE_URL=https://www.controlevr.com.br" set "DEST=%USERPROFILE%\Documents\ControleVR\ConferenciaEstoque" set "CACHE_BUSTER=%RANDOM%%RANDOM%" set "ZIPTMP=%TEMP%\conferencia_estoque_%CACHE_BUSTER%.zip" set "STAGING=%TEMP%\conferencia_estoque_extrai_%CACHE_BUSTER%" echo. echo Baixando arquivos da automacao (arquivo grande, pode demorar um pouco)... powershell -NoProfile -Command "try { Invoke-WebRequest -UseBasicParsing -Headers @{'Cache-Control'='no-cache'} -Uri '%BASE_URL%/static/automacao/conferencia_estoque.zip?v=%CACHE_BUSTER%' -OutFile '%ZIPTMP%'; 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_conferencia.cmd?v=%CACHE_BUSTER%' -OutFile '%TEMP%\abrir_conferencia_%CACHE_BUSTER%.cmd'; exit 0 } catch { exit 1 }" if errorlevel 1 goto :falha_download if not exist "%ZIPTMP%" goto :falha_download echo. echo Extraindo arquivos... mkdir "%STAGING%" 2>nul powershell -NoProfile -Command "try { Add-Type -AssemblyName System.IO.Compression.FileSystem; [System.IO.Compression.ZipFile]::ExtractToDirectory('%ZIPTMP%','%STAGING%'); exit 0 } catch { exit 1 }" if errorlevel 1 goto :falha_extracao if not exist "%STAGING%\iniciar_plataforma_conferencia.bat" goto :falha_extracao move /y "%TEMP%\abrir_conferencia_%CACHE_BUSTER%.cmd" "%STAGING%\abrir_conferencia.cmd" >nul if errorlevel 1 goto :falha_extracao :: Troca a pasta de destino de uma vez so (rename), evitando problemas de :: sincronizacao (OneDrive etc.) ao gravar milhares de arquivos direto no Documents. if exist "%DEST%" rd /s /q "%DEST%" >nul 2>&1 if not exist "%USERPROFILE%\Documents\ControleVR" mkdir "%USERPROFILE%\Documents\ControleVR" >nul 2>&1 move /y "%STAGING%" "%DEST%" >nul if errorlevel 1 goto :falha_extracao del /q "%ZIPTMP%" 2>nul if not exist "%DEST%\iniciar_plataforma_conferencia.bat" goto :falha_extracao if not exist "%DEST%\abrir_conferencia.cmd" goto :falha_extracao echo. echo Registrando a automacao neste computador... reg add "HKCU\Software\Classes\vrconferencia" /ve /d "URL:VR Conferencia Protocol" /f >nul if errorlevel 1 goto :falha_registro reg add "HKCU\Software\Classes\vrconferencia" /v "URL Protocol" /t REG_SZ /d "" /f >nul if errorlevel 1 goto :falha_registro reg add "HKCU\Software\Classes\vrconferencia\shell\open\command" /ve /d "\"%ComSpec%\" /d /s /c \"\"%DEST%\abrir_conferencia.cmd\" \"%%1\"\"" /f >nul if errorlevel 1 goto :falha_registro echo. echo Instalacao concluida! echo Pode voltar na plataforma e clicar em "Conferencia de Caracteristica de Estoque". echo. pause exit /b 0 :falha_download del /q "%ZIPTMP%" "%TEMP%\abrir_conferencia_%CACHE_BUSTER%.cmd" 2>nul echo. echo Falha ao baixar os arquivos. Verifique sua conexao com a internet e tente novamente. pause exit /b 1 :falha_extracao rd /s /q "%STAGING%" 2>nul del /q "%ZIPTMP%" 2>nul echo. echo Falha ao extrair os arquivos baixados. pause exit /b 1 :falha_registro echo. echo Os arquivos foram baixados, mas nao foi possivel registrar o botao na plataforma. echo Tente executar este instalador novamente. pause exit /b 1