From b5b331e82291812677a5641015064bc6b46be989 Mon Sep 17 00:00:00 2001 From: Flowseal Date: Wed, 30 Apr 2025 13:41:12 +0300 Subject: [PATCH] Services merge --- check_updates.bat | 37 --- discord.bat | 4 +- general (ALT).bat | 4 +- general (ALT2).bat | 4 +- general (ALT3).bat | 4 +- general (ALT4).bat | 4 +- general (ALT5).bat | 4 +- general (FAKE TLS MOD ALT).bat | 4 +- general (FAKE TLS MOD AUTO).bat | 4 +- general (FAKE TLS MOD).bat | 4 +- general (МГТС).bat | 4 +- general (МГТС2).bat | 4 +- general.bat | 4 +- service.bat | 405 ++++++++++++++++++++++++++++++++ service_diagnostics.bat | 131 ----------- service_install.bat | 137 ----------- service_remove.bat | 24 -- service_status.bat | 42 ---- 18 files changed, 429 insertions(+), 395 deletions(-) delete mode 100644 check_updates.bat create mode 100644 service.bat delete mode 100644 service_diagnostics.bat delete mode 100644 service_install.bat delete mode 100644 service_remove.bat delete mode 100644 service_status.bat diff --git a/check_updates.bat b/check_updates.bat deleted file mode 100644 index 653cd52..0000000 --- a/check_updates.bat +++ /dev/null @@ -1,37 +0,0 @@ -@echo off -setlocal EnableDelayedExpansion -chcp 437 > nul - -:: Set current version and URLs -set "LOCAL_VERSION=1.7.0" -set "GITHUB_VERSION_URL=https://raw.githubusercontent.com/Flowseal/zapret-discord-youtube/main/.service/version.txt" -set "GITHUB_RELEASE_URL=https://github.com/Flowseal/zapret-discord-youtube/releases/tag/" -set "GITHUB_DOWNLOAD_URL=https://github.com/Flowseal/zapret-discord-youtube/releases/latest/download/zapret-discord-youtube-" - -:: Get the latest version from GitHub -for /f "delims=" %%A in ('powershell -command "(Invoke-WebRequest -Uri \"%GITHUB_VERSION_URL%\" -Headers @{\"Cache-Control\"=\"no-cache\"} -TimeoutSec 5).Content.Trim()" 2^>nul') do set "GITHUB_VERSION=%%A" - -:: Error handling -if not defined GITHUB_VERSION ( - echo Error: Failed to fetch the latest version. Check your internet connection - goto :EOF -) - -:: Version comparison -if "%LOCAL_VERSION%"=="%GITHUB_VERSION%" ( - echo Latest version installed: %LOCAL_VERSION% -) else ( - echo New version available: %GITHUB_VERSION% - echo Release page: %GITHUB_RELEASE_URL%%GITHUB_VERSION% - - set /p "CHOICE=Do you want to automatically download the new version? (y/n, default: y): " - - if "!CHOICE!"=="" set "CHOICE=y" - - if /i "!CHOICE!"=="y" ( - echo Opening the download page... - start "" "%GITHUB_DOWNLOAD_URL%%GITHUB_VERSION%.rar" - ) -) -if not "%1"=="soft" pause -endlocal diff --git a/discord.bat b/discord.bat index 811567b..b3a8375 100644 --- a/discord.bat +++ b/discord.bat @@ -3,8 +3,8 @@ chcp 65001 > nul :: 65001 - UTF-8 cd /d "%~dp0" -call service_status.bat zapret -call check_updates.bat soft +call service.bat status_zapret +call service.bat check_updates echo: set "BIN=%~dp0bin\" diff --git a/general (ALT).bat b/general (ALT).bat index 0cbfb4a..40f4809 100644 --- a/general (ALT).bat +++ b/general (ALT).bat @@ -3,8 +3,8 @@ chcp 65001 > nul :: 65001 - UTF-8 cd /d "%~dp0" -call service_status.bat zapret -call check_updates.bat soft +call service.bat status_zapret +call service.bat check_updates echo: set "BIN=%~dp0bin\" diff --git a/general (ALT2).bat b/general (ALT2).bat index 2443a42..4c99dab 100644 --- a/general (ALT2).bat +++ b/general (ALT2).bat @@ -3,8 +3,8 @@ chcp 65001 > nul :: 65001 - UTF-8 cd /d "%~dp0" -call service_status.bat zapret -call check_updates.bat soft +call service.bat status_zapret +call service.bat check_updates echo: set "BIN=%~dp0bin\" diff --git a/general (ALT3).bat b/general (ALT3).bat index ea133e3..89e6897 100644 --- a/general (ALT3).bat +++ b/general (ALT3).bat @@ -3,8 +3,8 @@ chcp 65001 > nul :: 65001 - UTF-8 cd /d "%~dp0" -call service_status.bat zapret -call check_updates.bat soft +call service.bat status_zapret +call service.bat check_updates echo: set "BIN=%~dp0bin\" diff --git a/general (ALT4).bat b/general (ALT4).bat index 6d27731..2880089 100644 --- a/general (ALT4).bat +++ b/general (ALT4).bat @@ -3,8 +3,8 @@ chcp 65001 > nul :: 65001 - UTF-8 cd /d "%~dp0" -call service_status.bat zapret -call check_updates.bat soft +call service.bat status_zapret +call service.bat check_updates echo: set "BIN=%~dp0bin\" diff --git a/general (ALT5).bat b/general (ALT5).bat index 5c721dc..225cc51 100644 --- a/general (ALT5).bat +++ b/general (ALT5).bat @@ -4,8 +4,8 @@ chcp 65001 > nul :: NOT RECOMMENDED cd /d "%~dp0" -call service_status.bat zapret -call check_updates.bat soft +call service.bat status_zapret +call service.bat check_updates echo: set "BIN=%~dp0bin\" diff --git a/general (FAKE TLS MOD ALT).bat b/general (FAKE TLS MOD ALT).bat index 09b6e96..277e6d1 100644 --- a/general (FAKE TLS MOD ALT).bat +++ b/general (FAKE TLS MOD ALT).bat @@ -3,8 +3,8 @@ chcp 65001 > nul :: 65001 - UTF-8 cd /d "%~dp0" -call service_status.bat zapret -call check_updates.bat soft +call service.bat status_zapret +call service.bat check_updates echo: set "BIN=%~dp0bin\" diff --git a/general (FAKE TLS MOD AUTO).bat b/general (FAKE TLS MOD AUTO).bat index cbcf058..7129913 100644 --- a/general (FAKE TLS MOD AUTO).bat +++ b/general (FAKE TLS MOD AUTO).bat @@ -3,8 +3,8 @@ chcp 65001 > nul :: 65001 - UTF-8 cd /d "%~dp0" -call service_status.bat zapret -call check_updates.bat soft +call service.bat status_zapret +call service.bat check_updates echo: set "BIN=%~dp0bin\" diff --git a/general (FAKE TLS MOD).bat b/general (FAKE TLS MOD).bat index 09f1785..136cabd 100644 --- a/general (FAKE TLS MOD).bat +++ b/general (FAKE TLS MOD).bat @@ -3,8 +3,8 @@ chcp 65001 > nul :: 65001 - UTF-8 cd /d "%~dp0" -call service_status.bat zapret -call check_updates.bat soft +call service.bat status_zapret +call service.bat check_updates echo: set "BIN=%~dp0bin\" diff --git a/general (МГТС).bat b/general (МГТС).bat index 75975f1..70d7631 100644 --- a/general (МГТС).bat +++ b/general (МГТС).bat @@ -3,8 +3,8 @@ chcp 65001 > nul :: 65001 - UTF-8 cd /d "%~dp0" -call service_status.bat zapret -call check_updates.bat soft +call service.bat status_zapret +call service.bat check_updates echo: set "BIN=%~dp0bin\" diff --git a/general (МГТС2).bat b/general (МГТС2).bat index f9b9d0b..d83e3a4 100644 --- a/general (МГТС2).bat +++ b/general (МГТС2).bat @@ -3,8 +3,8 @@ chcp 65001 > nul :: 65001 - UTF-8 cd /d "%~dp0" -call service_status.bat zapret -call check_updates.bat soft +call service.bat status_zapret +call service.bat check_updates echo: set "BIN=%~dp0bin\" diff --git a/general.bat b/general.bat index ed4ccb8..bddf464 100644 --- a/general.bat +++ b/general.bat @@ -3,8 +3,8 @@ chcp 65001 > nul :: 65001 - UTF-8 cd /d "%~dp0" -call service_status.bat zapret -call check_updates.bat soft +call service.bat status_zapret +call service.bat check_updates echo: set "BIN=%~dp0bin\" diff --git a/service.bat b/service.bat new file mode 100644 index 0000000..cb28f90 --- /dev/null +++ b/service.bat @@ -0,0 +1,405 @@ +@echo off +setlocal EnableDelayedExpansion + +:: External commands +if "%~1"=="status_zapret" ( + call :test_service zapret soft + exit /b +) + +if "%~1"=="check_updates" ( + call :service_check_updates soft + exit /b +) + +if "%1"=="admin" ( + echo Started with admin rights +) else ( + echo Requesting admin rights... + powershell -Command "Start-Process 'cmd.exe' -ArgumentList '/c \"\"%~f0\" admin\"' -Verb RunAs" + exit /b +) + + +:: MENU ================================ +:menu +cls +set "menu_choice=null" +echo ======================= +echo 1. Install Service +echo 2. Remove Services +echo 3. Check Service Status +echo 4. Run Diagnostics +echo 5. Check updates +echo 0. Exit +set /p menu_choice=Enter choice (0-5): + +if "%menu_choice%"=="1" goto service_install +if "%menu_choice%"=="2" goto service_remove +if "%menu_choice%"=="3" goto service_status +if "%menu_choice%"=="4" goto service_diagnostics +if "%menu_choice%"=="5" goto service_check_updates +if "%menu_choice%"=="0" exit /b +goto menu + + +:: STATUS ============================== +:service_status +cls +chcp 65001 > nul +echo Checking services and tasks... +call :test_service zapret +call :test_service WinDivert + +tasklist /FI "IMAGENAME eq winws.exe" | find /I "winws.exe" > nul +if !errorlevel!==0 ( + echo Bypass is ACTIVE +) else ( + echo Bypass NOT FOUND +) + +pause +goto menu + +:test_service +set "ServiceName=%~1" +set "ServiceStatus=" + +for /f "tokens=3 delims=: " %%A in ('sc query "%ServiceName%" ^| findstr /i "STATE"') do set "ServiceStatus=%%A" +set "ServiceStatus=%ServiceStatus: =%" + +if "%ServiceStatus%"=="RUNNING" ( + if "%~2"=="soft" ( + echo "%ServiceName%" is ALREADY RUNNING as service, use "service_remove.bat" first if you want to run standalone bat. + pause + exit /b + ) else ( + echo "%ServiceName%" service is RUNNING. + ) +) else if not "%~2"=="soft" ( + echo "%ServiceName%" is NOT running. +) + +exit /b + + +:: REMOVE ============================== +:service_remove +cls +chcp 65001 > nul + +set SRVCNAME=zapret +net stop %SRVCNAME% +sc delete %SRVCNAME% + +net stop "WinDivert" +sc delete "WinDivert" +net stop "WinDivert14" +sc delete "WinDivert14" + +pause +goto menu + + +:: INSTALL ============================= +:service_install +cls +chcp 65001 > nul + +:: Main +cd /d "%~dp0" +set "BIN_PATH=%~dp0bin\" +set "LISTS_PATH=%~dp0lists\" + +:: Searching for .bat files in current folder, except files that start with "service" +echo Pick one of the options: +set "count=0" +for %%f in (*.bat) do ( + set "filename=%%~nxf" + if /i not "!filename:~0,7!"=="service" if /i not "!filename:~0,13!"=="check_updates" if /i not "!filename:~0,17!"=="cloudflare_switch" ( + set /a count+=1 + echo !count!. %%f + set "file!count!=%%f" + ) +) + +:: Choosing file +set "choice=" +set /p "choice=Input file index (number): " +if "!choice!"=="" goto :eof + +set "selectedFile=!file%choice%!" +if not defined selectedFile ( + echo Invalid choice, exiting... + pause + goto menu +) + +:: Args that should be followed by value +set "args_with_value=sni" + +:: Parsing args (mergeargs: 2=start param|3=arg with value|1=params args|0=default) +set "args=" +set "capture=0" +set "mergeargs=0" +set QUOTE=" + +for /f "tokens=*" %%a in ('type "!selectedFile!"') do ( + set "line=%%a" + + echo !line! | findstr /i "%BIN%winws.exe" >nul + if not errorlevel 1 ( + set "capture=1" + ) + + if !capture!==1 ( + if not defined args ( + set "line=!line:*%BIN%winws.exe"=!" + ) + + set "temp_args=" + for %%i in (!line!) do ( + set "arg=%%i" + + if not "!arg!"=="^" ( + if "!arg:~0,2!" EQU "--" if not !mergeargs!==0 ( + set "mergeargs=0" + ) + + if "!arg:~0,1!" EQU "!QUOTE!" ( + set "arg=!arg:~1,-1!" + + echo !arg! | findstr ":" >nul + if !errorlevel!==0 ( + set "arg=\!QUOTE!!arg!\!QUOTE!" + ) else if "!arg:~0,1!"=="@" ( + set "arg=\!QUOTE!@%~dp0!arg:~1!\!QUOTE!" + ) else if "!arg:~0,5!"=="%%BIN%%" ( + set "arg=\!QUOTE!!BIN_PATH!!arg:~5!\!QUOTE!" + ) else if "!arg:~0,7!"=="%%LISTS%%" ( + set "arg=\!QUOTE!!LISTS_PATH!!arg:~7!\!QUOTE!" + ) else ( + set "arg=\!QUOTE!%~dp0!arg!\!QUOTE!" + ) + ) + + if !mergeargs!==1 ( + set "temp_args=!temp_args!,!arg!" + ) else if !mergeargs!==3 ( + set "temp_args=!temp_args!=!arg!" + set "mergeargs=1" + ) else ( + set "temp_args=!temp_args! !arg!" + ) + + if "!arg:~0,2!" EQU "--" ( + set "mergeargs=2" + ) else if !mergeargs!==2 ( + set "mergeargs=1" + ) else if !mergeargs!==1 ( + for %%x in (!args_with_value!) do ( + if /i "%%x"=="!arg!" ( + set "mergeargs=3" + ) + ) + ) + ) + ) + + if not "!temp_args!"=="" ( + set "args=!args! !temp_args!" + ) + ) +) + +:: Creating service with parsed args +set ARGS=%args% +echo Final args: !ARGS! +set SRVCNAME=zapret + +net stop %SRVCNAME% >nul 2>&1 +sc delete %SRVCNAME% >nul 2>&1 +sc create %SRVCNAME% binPath= "\"%BIN_PATH%winws.exe\" %ARGS%" DisplayName= "zapret" start= auto +sc description %SRVCNAME% "Zapret DPI bypass software" +sc start %SRVCNAME% + +pause +goto menu + + +:: CHECK UPDATES ======================= +:service_check_updates +chcp 437 > nul + +:: Set current version and URLs +set "LOCAL_VERSION=1.7.0" +set "GITHUB_VERSION_URL=https://raw.githubusercontent.com/Flowseal/zapret-discord-youtube/main/.service/version.txt" +set "GITHUB_RELEASE_URL=https://github.com/Flowseal/zapret-discord-youtube/releases/tag/" +set "GITHUB_DOWNLOAD_URL=https://github.com/Flowseal/zapret-discord-youtube/releases/latest/download/zapret-discord-youtube-" + +:: Get the latest version from GitHub +for /f "delims=" %%A in ('powershell -command "(Invoke-WebRequest -Uri \"%GITHUB_VERSION_URL%\" -Headers @{\"Cache-Control\"=\"no-cache\"} -TimeoutSec 5).Content.Trim()" 2^>nul') do set "GITHUB_VERSION=%%A" + +:: Error handling +if not defined GITHUB_VERSION ( + echo Error: Failed to fetch the latest version. Check your internet connection + pause + goto menu +) + +:: Version comparison +if "%LOCAL_VERSION%"=="%GITHUB_VERSION%" ( + echo Latest version installed: %LOCAL_VERSION% +) else ( + echo New version available: %GITHUB_VERSION% + echo Release page: %GITHUB_RELEASE_URL%%GITHUB_VERSION% + + set "CHOICE=" + set /p "CHOICE=Do you want to automatically download the new version? (Y/N) (default: Y) " + if "!CHOICE!"=="" set "CHOICE=Y" + if "!CHOICE!"=="y" set "CHOICE=Y" + + if /i "!CHOICE!"=="Y" ( + echo Opening the download page... + start "" "%GITHUB_DOWNLOAD_URL%%GITHUB_VERSION%.rar" + ) +) + +if "%1"=="soft" exit /b +pause +goto menu + + +:: DIAGNOSTICS ========================= +:service_diagnostics +chcp 437 > nul +cls + +:: AdguardSvc.exe +tasklist /FI "IMAGENAME eq AdguardSvc.exe" | find /I "AdguardSvc.exe" > nul +if !errorlevel!==0 ( + call :PrintRed "[X] Adguard process found. Adguard may cause problems with Discord" + call :PrintRed "https://github.com/Flowseal/zapret-discord-youtube/issues/417" +) else ( + call :PrintGreen "Adguard check passed" +) +echo: + +:: Killer +sc query | findstr /I "Killer" > nul +if !errorlevel!==0 ( + call :PrintRed "[X] Killer services found. Killer conflicts with zapret" + call :PrintRed "https://github.com/Flowseal/zapret-discord-youtube/issues/2512#issuecomment-2821119513" +) else ( + call :PrintGreen "Killer check passed" +) +echo: + +:: Check Point +set "checkpointFound=0" +sc query | findstr /I "TracSrvWrapper" > nul +if !errorlevel!==0 ( + set "checkpointFound=1" +) + +sc query | findstr /I "EPWD" > nul +if !errorlevel!==0 ( + set "checkpointFound=1" +) + +if !checkpointFound!==1 ( + call :PrintRed "[X] Check Point services found. Check Point conflicts with zapret" + call :PrintRed "Try to uninstall Check Point" +) else ( + call :PrintGreen "Check Point check passed" +) +echo: + +:: SmartByte +sc query | findstr /I "SmartByte" > nul +if !errorlevel!==0 ( + call :PrintRed "[X] SmartByte services found. SmartByte conflicts with zapret" + call :PrintRed "Try to uninstall or disable SmartByte through services.msc" +) else ( + call :PrintGreen "SmartByte check passed" +) +echo: + +:: VPN +sc query | findstr /I "VPN" > nul +if !errorlevel!==0 ( + call :PrintYellow "[?] Some VPN services found. Some VPNs can conflict with zapret" + call :PrintYellow "Make sure that all VPNs are disabled" +) else ( + call :PrintGreen "VPN check passed" +) +echo: + +:: DNS +set "dnsfound=0" +for /f "skip=1 tokens=*" %%a in ('wmic nicconfig where "IPEnabled=true" get DNSServerSearchOrder /format:table') do ( + echo %%a | findstr /i "192.168." >nul + if !errorlevel!==0 ( + set "dnsfound=1" + ) +) +if !dnsfound!==1 ( + call :PrintYellow "[?] DNS servers are probably not specified." + call :PrintYellow "Provider's DNS servers are automatically used, which may affect zapret. It is recommended to install well-known DNS servers and setup DoH" +) else ( + call :PrintGreen "DNS check passed" +) +echo: + +:: Discord cache clearing +set "CHOICE=" +set /p "CHOICE=Do you want to clear the Discord cache? (Y/N) (default: Y) " +if "!CHOICE!"=="" set "CHOICE=Y" +if "!CHOICE!"=="y" set "CHOICE=Y" + +if /i "!CHOICE!"=="Y" ( + tasklist /FI "IMAGENAME eq Discord.exe" | findstr /I "Discord.exe" > nul + if !errorlevel!==0 ( + echo Discord is running, closing... + taskkill /IM Discord.exe /F > nul + if !errorlevel! == 0 ( + call :PrintGreen "Discord was successfully closed" + ) else ( + call :PrintRed "Unable to close Discord" + ) + ) + + set "discordCacheDir=%appdata%\discord" + + for %%d in ("Cache" "Code Cache" "GPUCache") do ( + set "dirPath=!discordCacheDir!\%%~d" + if exist "!dirPath!" ( + rd /s /q "!dirPath!" + if !errorlevel!==0 ( + call :PrintGreen "Successfully deleted !dirPath!" + ) else ( + call :PrintRed "Failed to delete !dirPath!" + ) + ) else ( + call :PrintRed "!dirPath! does not exist" + ) + ) +) +echo: + +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 \ No newline at end of file diff --git a/service_diagnostics.bat b/service_diagnostics.bat deleted file mode 100644 index 7b0fa9f..0000000 --- a/service_diagnostics.bat +++ /dev/null @@ -1,131 +0,0 @@ -@echo off -setlocal EnableDelayedExpansion - -:: Admin rights check -if "%1"=="admin" ( - echo Started with admin rights - cls -) else ( - echo Requesting admin rights... - powershell -Command "Start-Process 'cmd.exe' -ArgumentList '/c \"\"%~f0\" admin\"' -Verb RunAs" - exit /b -) - -:: AdguardSvc.exe -tasklist /FI "IMAGENAME eq AdguardSvc.exe" | find /I "AdguardSvc.exe" > nul -if !errorlevel!==0 ( - call :PrintRed "[X] Adguard process found. Adguard may cause problems with Discord" - call :PrintRed "https://github.com/Flowseal/zapret-discord-youtube/issues/417" -) else ( - call :PrintGreen "Adguard check passed" -) -echo: - -:: Killer -sc query | findstr /I "Killer" > nul -if !errorlevel!==0 ( - call :PrintRed "[X] Killer services found. Killer conflicts with zapret" - call :PrintRed "https://github.com/Flowseal/zapret-discord-youtube/issues/2512#issuecomment-2821119513" -) else ( - call :PrintGreen "Killer check passed" -) -echo: - -:: Check Point -sc query | findstr /I "Check" | findstr /I "Point" > nul -if !errorlevel!==0 ( - call :PrintRed "[X] Check Point services found. Check Point conflicts with zapret" - call :PrintRed "Try to uninstall Check Point" -) else ( - call :PrintGreen "Check Point check passed" -) -echo: - -:: SmartByte -sc query | findstr /I "SmartByte" > nul -if !errorlevel!==0 ( - call :PrintRed "[X] SmartByte services found. SmartByte conflicts with zapret" - call :PrintRed "Try to uninstall or disable SmartByte through services.msc" -) else ( - call :PrintGreen "SmartByte check passed" -) -echo: - -:: VPN -sc query | findstr /I "VPN" > nul -if !errorlevel!==0 ( - call :PrintYellow "[?] Some VPN services found. Some VPNs can conflict with zapret" - call :PrintYellow "Make sure that all VPNs are disabled" -) else ( - call :PrintGreen "VPN check passed" -) -echo: - -:: DNS -set "dnsfound=0" -for /f "skip=1 tokens=*" %%a in ('wmic nicconfig where "IPEnabled=true" get DNSServerSearchOrder /format:table') do ( - echo %%a | findstr /i "192.168." >nul - if !errorlevel!==0 ( - set "dnsfound=1" - ) -) -if !dnsfound!==1 ( - call :PrintYellow "[?] DNS servers are probably not specified." - call :PrintYellow "Provider's DNS servers are automatically used, which may affect zapret. It is recommended to install well-known DNS servers and setup DoH" -) else ( - call :PrintGreen "DNS check passed" -) -echo: - -:: Discord cache clearing -echo Do you want to clear the Discord cache? (Y/N) (default: Y) -set /p answer= -if "%answer%"=="" set answer=Y -if "%answer%"=="y" set answer=Y - -if /i "%answer%"=="Y" ( - tasklist /FI "IMAGENAME eq Discord.exe" | findstr /I "Discord.exe" > nul - if !errorlevel!==0 ( - echo Discord is running, closing... - taskkill /IM Discord.exe /F > nul - if !errorlevel! == 0 ( - call :PrintGreen "Discord was successfully closed" - ) else ( - call :PrintRed "Unable to close Discord" - ) - ) - - set "discordCacheDir=%appdata%\discord" - - for %%d in ("Cache" "Code Cache" "GPUCache") do ( - set "dirPath=!discordCacheDir!\%%~d" - if exist "!dirPath!" ( - rd /s /q "!dirPath!" - if !errorlevel!==0 ( - call :PrintGreen "Successfully deleted !dirPath!" - ) else ( - call :PrintRed "Failed to delete !dirPath!" - ) - ) else ( - call :PrintRed "!dirPath! does not exist" - ) - ) -) -echo: - -pause -exit /b - -:: 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 \ No newline at end of file diff --git a/service_install.bat b/service_install.bat deleted file mode 100644 index dbca19a..0000000 --- a/service_install.bat +++ /dev/null @@ -1,137 +0,0 @@ -@echo off -setlocal EnableDelayedExpansion -chcp 65001 > nul -:: 65001 - UTF-8 - -:: Admin rights check -if "%1"=="admin" ( - echo Started with admin rights -) else ( - echo Requesting admin rights... - powershell -Command "Start-Process 'cmd.exe' -ArgumentList '/c \"\"%~f0\" admin\"' -Verb RunAs" - exit /b -) - -:: Main -cd /d "%~dp0" -set "BIN_PATH=%~dp0bin\" -set "LISTS_PATH=%~dp0lists\" - -:: Checking for updates -call check_updates.bat soft -echo: - -:: Searching for .bat files in current folder, except files that start with "service" -echo Pick one of the options: -set "count=0" -for %%f in (*.bat) do ( - set "filename=%%~nxf" - if /i not "!filename:~0,7!"=="service" if /i not "!filename:~0,13!"=="check_updates" if /i not "!filename:~0,17!"=="cloudflare_switch" ( - set /a count+=1 - echo !count!. %%f - set "file!count!=%%f" - ) -) - -:: Choosing file -set "choice=" -set /p "choice=Input file index (number): " -if "!choice!"=="" goto :eof - -set "selectedFile=!file%choice%!" -if not defined selectedFile ( - echo Wrong choice, exiting... - pause - goto :eof -) - -:: Args that should be followed by value -set "args_with_value=sni" - -:: Parsing args (mergeargs: 2=start param|3=arg with value|1=params args|0=default) -set "args=" -set "capture=0" -set "mergeargs=0" -set QUOTE=" - -for /f "tokens=*" %%a in ('type "!selectedFile!"') do ( - set "line=%%a" - - echo !line! | findstr /i "%BIN%winws.exe" >nul - if not errorlevel 1 ( - set "capture=1" - ) - - if !capture!==1 ( - if not defined args ( - set "line=!line:*%BIN%winws.exe"=!" - ) - - set "temp_args=" - for %%i in (!line!) do ( - set "arg=%%i" - - if not "!arg!"=="^" ( - if "!arg:~0,2!" EQU "--" if not !mergeargs!==0 ( - set "mergeargs=0" - ) - - if "!arg:~0,1!" EQU "!QUOTE!" ( - set "arg=!arg:~1,-1!" - - echo !arg! | findstr ":" >nul - if !errorlevel!==0 ( - set "arg=\!QUOTE!!arg!\!QUOTE!" - ) else if "!arg:~0,1!"=="@" ( - set "arg=\!QUOTE!@%~dp0!arg:~1!\!QUOTE!" - ) else if "!arg:~0,5!"=="%%BIN%%" ( - set "arg=\!QUOTE!!BIN_PATH!!arg:~5!\!QUOTE!" - ) else if "!arg:~0,7!"=="%%LISTS%%" ( - set "arg=\!QUOTE!!LISTS_PATH!!arg:~7!\!QUOTE!" - ) else ( - set "arg=\!QUOTE!%~dp0!arg!\!QUOTE!" - ) - ) - - if !mergeargs!==1 ( - set "temp_args=!temp_args!,!arg!" - ) else if !mergeargs!==3 ( - set "temp_args=!temp_args!=!arg!" - set "mergeargs=1" - ) else ( - set "temp_args=!temp_args! !arg!" - ) - - if "!arg:~0,2!" EQU "--" ( - set "mergeargs=2" - ) else if !mergeargs!==2 ( - set "mergeargs=1" - ) else if !mergeargs!==1 ( - for %%x in (!args_with_value!) do ( - if /i "%%x"=="!arg!" ( - set "mergeargs=3" - ) - ) - ) - ) - ) - - if not "!temp_args!"=="" ( - set "args=!args! !temp_args!" - ) - ) -) - -:: Creating service with parsed args -set ARGS=%args% -echo Final args: !ARGS! -set SRVCNAME=zapret - -net stop %SRVCNAME% >nul 2>&1 -sc delete %SRVCNAME% >nul 2>&1 -sc create %SRVCNAME% binPath= "\"%BIN_PATH%winws.exe\" %ARGS%" DisplayName= "zapret" start= auto -sc description %SRVCNAME% "Zapret DPI bypass software" -sc start %SRVCNAME% - -pause -endlocal diff --git a/service_remove.bat b/service_remove.bat deleted file mode 100644 index 6763b80..0000000 --- a/service_remove.bat +++ /dev/null @@ -1,24 +0,0 @@ -@echo off -chcp 65001 > nul -:: 65001 - UTF-8 - -if "%1"=="admin" ( - echo Started with admin rights -) else ( - echo Requesting admin rights... - powershell -Command "Start-Process 'cmd.exe' -ArgumentList '/c \"\"%~f0\" admin\"' -Verb RunAs" - exit /b -) - -set SRVCNAME=zapret - -net stop %SRVCNAME% -sc delete %SRVCNAME% - -net stop "WinDivert" -sc delete "WinDivert" -net stop "WinDivert14" -sc delete "WinDivert14" - -pause -endlocal diff --git a/service_status.bat b/service_status.bat deleted file mode 100644 index 7b8dcd5..0000000 --- a/service_status.bat +++ /dev/null @@ -1,42 +0,0 @@ -@echo off -setlocal EnableDelayedExpansion -chcp 65001 > nul -:: 65001 - UTF-8 - -if "%~1"=="" ( - echo Checking services and tasks... - call :test_service zapret - call :test_service WinDivert - tasklist /FI "IMAGENAME eq winws.exe" | find /I "winws.exe" > nul - if !errorlevel!==0 ( - echo Bypass is ACTIVE - ) else ( - echo Bypass NOT FOUND - ) - pause -) else ( - call :test_service "%~1" "soft" -) - -exit /b - -:test_service -set "ServiceName=%~1" -set "ServiceStatus=" - -for /f "tokens=3 delims=: " %%A in ('sc query "%ServiceName%" ^| findstr /i "STATE"') do set "ServiceStatus=%%A" - -set "ServiceStatus=%ServiceStatus: =%" - -if "%ServiceStatus%"=="RUNNING" ( - if "%~2"=="soft" ( - echo "%ServiceName%" is ALREADY RUNNING as service, use "service_remove.bat" first if you want to run standalone bat. - pause - ) else ( - echo "%ServiceName%" service is RUNNING. - ) -) else if not "%~2"=="soft" ( - echo "%ServiceName%" is NOT running. -) - -exit /b