From 651342d06ff440e9e0349f30c45bbc54480bddf9 Mon Sep 17 00:00:00 2001 From: Flowseal Date: Thu, 25 Dec 2025 15:57:15 +0300 Subject: [PATCH] external commands check --- service.bat | 56 +++++++++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/service.bat b/service.bat index efbd66b..58d0604 100644 --- a/service.bat +++ b/service.bat @@ -25,10 +25,15 @@ if "%~1"=="load_game_filter" ( exit /b ) - if "%1"=="admin" ( + call :check_command chcp + call :check_command find + call :check_command findstr + call :check_command netsh + echo Started with admin rights ) else ( + call :check_command powershell echo Requesting admin rights... powershell -Command "Start-Process 'cmd.exe' -ArgumentList '/c \"\"%~f0\" admin\"' -Verb RunAs" exit @@ -809,36 +814,12 @@ echo Finished pause goto menu -:: Utility functions - -:PrintGreen -powershell -Command "Write-Host \"%~1\" -ForegroundColor Green" -exit /b - -:PrintRed -powershell -Command "Write-Host \"%~1\" -ForegroundColor Red" -exit /b - -:PrintYellow -powershell -Command "Write-Host \"%~1\" -ForegroundColor Yellow" -exit /b - :: RUN TESTS ============================= :run_tests chcp 65001 >nul cls -:: Check PowerShell -where powershell >nul 2>&1 -if %errorLevel% neq 0 ( - echo PowerShell is not installed or not in PATH. - echo Please install PowerShell and rerun this script. - echo. - pause - goto menu -) - :: Require PowerShell 2.0+ powershell -NoProfile -Command "if ($PSVersionTable -and $PSVersionTable.PSVersion -and $PSVersionTable.PSVersion.Major -ge 2) { exit 0 } else { exit 1 }" >nul 2>&1 if %errorLevel% neq 0 ( @@ -854,3 +835,28 @@ echo. start "" powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0utils\test zapret.ps1" pause goto menu + + +:: Utility functions + +:PrintGreen +powershell -Command "Write-Host \"%~1\" -ForegroundColor Green" +exit /b + +:PrintRed +powershell -Command "Write-Host \"%~1\" -ForegroundColor Red" +exit /b + +:PrintYellow +powershell -Command "Write-Host \"%~1\" -ForegroundColor Yellow" +exit /b + +:check_command +where %1 >nul 2>&1 +if %errorLevel% neq 0 ( + echo [ERROR] %1 not found in PATH + echo Fix your PATH variable with instructions here https://github.com/Flowseal/zapret-discord-youtube/issues/7490 + pause + exit /b 1 +) +exit /b 0 \ No newline at end of file